Skip to content

Commit 484426c

Browse files
committed
Delegate Serializer.attributes to Serializer.attribute
1 parent ee40e9f commit 484426c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/active_model/serializer.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,16 @@ def self.inherited(base)
5050

5151
def self.attributes(*attrs)
5252
attrs = attrs.first if attrs.first.class == Array
53-
_attributes.concat(attrs)
54-
_attributes.uniq!
5553

5654
attrs.each do |attr|
57-
define_method attr do
58-
object && object.read_attribute_for_serialization(attr)
59-
end unless method_defined?(attr) || _fragmented.respond_to?(attr)
55+
attribute(attr)
6056
end
6157
end
6258

6359
def self.attribute(attr, options = {})
6460
key = options.fetch(:key, attr)
65-
self._attributes_keys[attr] = { key: key } if key != attr
66-
self._attributes << key unless _attributes.include?(key)
61+
_attributes_keys[attr] = { key: key } if key != attr
62+
_attributes << key unless _attributes.include?(key)
6763

6864
ActiveModelSerializers.silence_warnings do
6965
define_method key do

0 commit comments

Comments
 (0)