Module: Pathway::Plugins::SequelModels::DSLMethods
- Defined in:
- lib/pathway/plugins/sequel_models.rb
Instance Method Summary collapse
Instance Method Details
#after_commit(step_name = nil, &bl) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pathway/plugins/sequel_models.rb', line 23 def after_commit(step_name = nil, &bl) fail 'must provide a step or a block but not both' if !step_name.nil? == block_given? if step_name after_commit { step step_name } else around(-> steps, state { dsl = self.class::DSL.new(State.new(self, state.to_h.dup), self) db.after_commit do steps.call(dsl) end }, &bl) end end |
#transaction(step_name = nil, &bl) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pathway/plugins/sequel_models.rb', line 9 def transaction(step_name = nil, &bl) fail 'must provide a step or a block but not both' if !step_name.nil? == block_given? if step_name transaction { step step_name } else around(-> steps, _ { db.transaction(savepoint: true) do raise Sequel::Rollback if steps.call.failure? end }, &bl) end end |