Module: ActiveData::Model::Lifecycle::ClassMethods
- Defined in:
- lib/active_data/model/lifecycle.rb
Instance Method Summary collapse
-
#create(*args) ⇒ Object
Initializes new instance with attributes passed and calls
save
on it. -
#create!(*args) ⇒ Object
Initializes new instance with attributes passed and calls
save!
on it.
Instance Method Details
#create(*args) ⇒ Object
Initializes new instance with attributes passed and calls save
on it. Returns instance in any case.
118 119 120 |
# File 'lib/active_data/model/lifecycle.rb', line 118 def create(*args) new(*args).tap(&:save) end |
#create!(*args) ⇒ Object
Initializes new instance with attributes passed and calls save!
on it. Returns instance in case of success and raises ActiveData::ValidationError or ActiveData::ObjectNotSaved in case of validation or saving fail respectively.
126 127 128 |
# File 'lib/active_data/model/lifecycle.rb', line 126 def create!(*args) new(*args).tap(&:save!) end |