From 484426ce17dd060b0029b54988670ac5458a0e1c Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 16 Sep 2015 23:21:44 -0500 Subject: [PATCH] Delegate Serializer.attributes to Serializer.attribute --- lib/active_model/serializer.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 6e00c2db8..8909bb79c 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -50,20 +50,16 @@ def self.inherited(base) def self.attributes(*attrs) attrs = attrs.first if attrs.first.class == Array - _attributes.concat(attrs) - _attributes.uniq! attrs.each do |attr| - define_method attr do - object && object.read_attribute_for_serialization(attr) - end unless method_defined?(attr) || _fragmented.respond_to?(attr) + attribute(attr) end end def self.attribute(attr, options = {}) key = options.fetch(:key, attr) - self._attributes_keys[attr] = { key: key } if key != attr - self._attributes << key unless _attributes.include?(key) + _attributes_keys[attr] = { key: key } if key != attr + _attributes << key unless _attributes.include?(key) ActiveModelSerializers.silence_warnings do define_method key do