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
saveon 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.
120 121 122 |
# File 'lib/active_data/model/lifecycle.rb', line 120 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.
128 129 130 |
# File 'lib/active_data/model/lifecycle.rb', line 128 def create! *args new(*args).tap(&:save!) end |