Class: UseCase::Base
- Inherits:
-
Object
- Object
- UseCase::Base
- Defined in:
- lib/usecasing_validations.rb
Direct Known Subclasses
Class Method Summary collapse
- .depends_all(*deps) ⇒ Object
- .ignored_dependencies ⇒ Object
- .not_ignored(usecase) ⇒ Object
- .tx(execution_order, context) ⇒ Object
Class Method Details
.depends_all(*deps) ⇒ Object
21 22 23 24 25 |
# File 'lib/usecasing_validations.rb', line 21 def self.depends_all(*deps) @dependencies ||= [] @dependencies.push(*deps) ignored_dependencies.push(*deps) end |
.ignored_dependencies ⇒ Object
27 28 29 |
# File 'lib/usecasing_validations.rb', line 27 def self.ignored_dependencies @ignored_dependencies ||= [] end |
.not_ignored(usecase) ⇒ Object
31 32 33 |
# File 'lib/usecasing_validations.rb', line 31 def self.not_ignored(usecase) !ignored_dependencies.include?(usecase) end |
.tx(execution_order, context) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/usecasing_validations.rb', line 35 def self.tx(execution_order, context) ctx = Context.new(context) executed = [] execution_order.each do |usecase| break if not_ignored(usecase) && !ctx.success? executed.push(usecase) yield usecase, ctx end rollback(executed, ctx) unless ctx.success? ctx end |