Delegate Serializer.attributes to Serializer.attribute

This commit is contained in:
Benjamin Fleischer 2015-09-16 23:21:44 -05:00
parent ee40e9fcef
commit 484426ce17

View File

@ -50,20 +50,16 @@ module ActiveModel
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