class ActiveModel::Serializer
def attribute(attr, options={})
def attribute(attr, options={}) self._attributes = _attributes.merge(attr.is_a?(Hash) ? attr : {attr => options[:key] || attr.to_s.gsub(/\?$/, '').to_sym}) attr = attr.keys[0] if attr.is_a? Hash unless method_defined?(attr) define_method attr do object.read_attribute_for_serialization(attr.to_sym) end end define_include_method attr # protect inheritance chains and open classes # if a serializer inherits from another OR # attributes are added later in a classes lifecycle # poison the cache define_method :_fast_attributes do raise NameError end end