module ActiveModel::Serializer::Attributes::ClassMethods
def _attributes
- See: Serializer::attribute -
Other tags:
- Api: - private
def _attributes _attributes_data.keys end
def _attributes_keys
- See: FragmentCache#fragment_serializer -
See: Serializer::attribute -
Other tags:
- Api: - private
def _attributes_keys _attributes_data .each_with_object({}) do |(key, attr), hash| next if key == attr.name hash[attr.name] = { key: key } end end
def attribute(attr, options = {}, &block)
object.edits.last(5)
def recent_edits
end
"#{object.first_name} #{object.last_name}"
attribute :full_name do
attribute :name, key: :title
attributes :id, :recent_edits
class AdminAuthorSerializer < ActiveModel::Serializer
@example
def attribute(attr, options = {}, &block) key = options.fetch(:key, attr) _attributes_data[key] = Attribute.new(attr, options, block) end
def attributes(*attrs)
class AdminAuthorSerializer < ActiveModel::Serializer
@example
def attributes(*attrs) attrs = attrs.first if attrs.first.class == Array attrs.each do |attr| attribute(attr) end end
def inherited(base)
def inherited(base) super base._attributes_data = _attributes_data.dup end