Module: ActiveModel::Attribute

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_model/attribute.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



56
57
58
# File 'lib/active_model/attribute.rb', line 56

def attributes
  slice(*self.class.attributes)
end

#initialize(attrs = {}) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/active_model/attribute.rb', line 48

def initialize(attrs = {})
  @attributes = {}

  assign_attributes(attrs) if attrs

  super()
end

#slice(*attrs) ⇒ Object



60
61
62
63
64
# File 'lib/active_model/attribute.rb', line 60

def slice(*attrs)
  attrs.each_with_object({}) do |name, hash|
    hash[name] = send(name)
  end
end