Method: ActiveModel::API#initialize
- Defined in:
- lib/active_model/api.rb
#initialize(attributes = {}) ⇒ Object
Initializes a new model with the given params
.
class Person
include ActiveModel::API
attr_accessor :name, :age
end
person = Person.new(name: 'bob', age: '18')
person.name # => "bob"
person.age # => "18"
80 81 82 83 84 |
# File 'lib/active_model/api.rb', line 80 def initialize(attributes = {}) assign_attributes(attributes) if attributes super() end |