Module: ObjectAttorney::OrmHandlers::SmoothOperator
- Defined in:
- lib/object_attorney/orm_handlers/smooth_operator.rb
Instance Method Summary collapse
- #call_save_or_destroy(object, save_method, options = {}) ⇒ Object
- #destroy(options = {}) ⇒ Object
- #save(options = {}) ⇒ Object
- #save!(options = {}) ⇒ Object
- #submit(options = {}) ⇒ Object
- #submit!(options = {}) ⇒ Object
Instance Method Details
#call_save_or_destroy(object, save_method, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/object_attorney/orm_handlers/smooth_operator.rb', line 27 def call_save_or_destroy(object, save_method, = {}) if object == self || object == represented_object represented_object.present? ? represented_object.send(save_method, ).ok? : true else save_method = :destroy if Helpers.marked_for_destruction?(object) object.send(save_method, ).ok? end end |
#destroy(options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/object_attorney/orm_handlers/smooth_operator.rb', line 22 def destroy( = {}) return true if represented_object.blank? represented_object.destroy().ok? end |
#save(options = {}) ⇒ Object
6 7 8 |
# File 'lib/object_attorney/orm_handlers/smooth_operator.rb', line 6 def save( = {}) save_or_! { submit() } end |
#save!(options = {}) ⇒ Object
10 11 12 |
# File 'lib/object_attorney/orm_handlers/smooth_operator.rb', line 10 def save!( = {}) save_or_! { submit!() } end |
#submit(options = {}) ⇒ Object
14 15 16 |
# File 'lib/object_attorney/orm_handlers/smooth_operator.rb', line 14 def submit( = {}) submit_or_!(:save, ) end |
#submit!(options = {}) ⇒ Object
18 19 20 |
# File 'lib/object_attorney/orm_handlers/smooth_operator.rb', line 18 def submit!( = {}) submit_or_!(:save!, ) end |