Method: ActiveModel::Attributes#attributes
- Defined in:
- activemodel/lib/active_model/attributes.rb
#attributes ⇒ Object
Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
class Person
include ActiveModel::Attributes
attribute :name, :string
attribute :age, :integer
end
person = Person.new
person.name = "Francesco"
person.age = 22
person.attributes # => { "name" => "Francesco", "age" => 22}
131 132 133 |
# File 'activemodel/lib/active_model/attributes.rb', line 131 def attributes @attributes.to_hash end |