module ActiveModel::Serializer::Attributes
Public Instance Methods
attributes(requested_attrs = nil, reload = false)
click to toggle source
Return the attributes
of object
as presented by the serializer.
# File lib/active_model/serializer/concerns/attributes.rb, line 17 def attributes(requested_attrs = nil, reload = false) @attributes = nil if reload @attributes ||= self.class._attributes_data.each_with_object({}) do |(key, attr), hash| next if attr.excluded?(self) next unless requested_attrs.nil? || requested_attrs.include?(key) hash[key] = attr.value(self) end end