Class: Macros::Model::Persist
Overview
Persist object from the context
Instance Method Summary collapse
- #call(ctx) ⇒ Object
-
#initialize(ctx_key: :model, method: :save!) ⇒ Persist
constructor
A new instance of Persist.
Methods inherited from Base
Constructor Details
#initialize(ctx_key: :model, method: :save!) ⇒ Persist
Returns a new instance of Persist.
9 10 11 12 |
# File 'lib/macros/model/persist.rb', line 9 def initialize(ctx_key: :model, method: :save!) @ctx_key = ctx_key @method = method end |
Instance Method Details
#call(ctx) ⇒ Object
14 15 16 17 18 |
# File 'lib/macros/model/persist.rb', line 14 def call(ctx, **) return false unless ctx[@ctx_key] ctx[@ctx_key].public_send(@method) end |