class ActiveModelSerializers::Model
def self.attributes(*names)
-
name
(String, Symbol
) -- -
names
(Array
) --
Overloads:
-
attributes(names)
Other tags:
- Note: - For now, the Model only supports the notion of 'attributes'.
def self.attributes(*names) self.attribute_names |= names.map(&:to_sym) # Silence redefinition of methods warnings ActiveModelSerializers.silence_warnings do attr_accessor(*names) end end
def self.derive_attributes_from_names_and_fix_accessors
def self.derive_attributes_from_names_and_fix_accessors unless included_modules.include?(DeriveAttributesFromNamesAndFixAccessors) prepend(DeriveAttributesFromNamesAndFixAccessors) end end
def cache_key
-
(String)
-
def cache_key ActiveSupport::Cache.expand_cache_key([ self.class.model_name.name.downcase, "#{id}-#{updated_at.strftime('%Y%m%d%H%M%S%9N')}" ].compact) end
def id
-
(String, Numeric, Symbol)
-
Other tags:
- Note: - Though +id+ is defined, it will only show up
def id attributes.fetch(:id) do defined?(@id) ? @id : self.class.model_name.name && self.class.model_name.name.downcase end end
def initialize(attributes = {})
-
attributes
(Hash
) --
def initialize(attributes = {}) attributes ||= {} # protect against nil @attributes = attributes.symbolize_keys.with_indifferent_access @errors = ActiveModel::Errors.new(self) super end
def updated_at
-
(String, Numeric, Time)
-
Other tags:
- Note: - Though +updated_at+ and +updated_at=+ are defined, it will only show up
def updated_at attributes.fetch(:updated_at) do defined?(@updated_at) ? @updated_at : File.mtime(__FILE__) end end