Module: Pathway::Plugins::SequelModels::DSLMethods
- Defined in:
- lib/pathway/plugins/sequel_models.rb
Instance Method Summary collapse
- #after_commit(step_name = nil, if: nil, unless: nil, &steps) ⇒ Object
- #after_rollback(step_name = nil, if: nil, unless: nil, &steps) ⇒ Object
- #transaction(step_name = nil, if: nil, unless: nil, &steps) ⇒ Object
Instance Method Details
#after_commit(step_name = nil, if: nil, unless: nil, &steps) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/pathway/plugins/sequel_models.rb', line 17 def after_commit(step_name = nil, if: nil, unless: nil, &steps) _with_db_steps(steps, step_name, *_opts_if_unless(binding)) do |runner, state| dsl_copy = _dsl_for(state) db.after_commit { runner.call(dsl_copy) } end end |
#after_rollback(step_name = nil, if: nil, unless: nil, &steps) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/pathway/plugins/sequel_models.rb', line 24 def after_rollback(step_name = nil, if: nil, unless: nil, &steps) _with_db_steps(steps, step_name, *_opts_if_unless(binding)) do |runner, state| dsl_copy = _dsl_for(state) db.after_rollback(savepoint: true) { runner.call(dsl_copy) } end end |
#transaction(step_name = nil, if: nil, unless: nil, &steps) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/pathway/plugins/sequel_models.rb', line 9 def transaction(step_name = nil, if: nil, unless: nil, &steps) _with_db_steps(steps, step_name, *_opts_if_unless(binding)) do |runner| db.transaction(savepoint: true) do raise Sequel::Rollback if runner.call.failure? end end end |