Module: ActiveModel::Attribute

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

Instance Method Summary collapse

Instance Method Details

#attributesObject



54
55
56
# File 'lib/active_model/attribute.rb', line 54

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

#initialize(attrs = {}) ⇒ Object



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

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

  assign_attributes(attrs) if attrs

  super()
end

#slice(*attrs) ⇒ Object



58
59
60
61
62
# File 'lib/active_model/attribute.rb', line 58

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