Module: IIInteractor::Core
Instance Method Summary collapse
- #call ⇒ Object
- #call_all ⇒ Object
- #call_self ⇒ Object
- #fail!(data = {}) ⇒ Object
- #inform(*args) ⇒ Object
- #initialize(context = {}, &block) ⇒ Object
- #rollback ⇒ Object
- #stop!(data = {}) ⇒ Object
Instance Method Details
#call ⇒ Object
37 38 |
# File 'lib/ii_interactor/core.rb', line 37 def call end |
#call_all ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ii_interactor/core.rb', line 19 def call_all planned = coactors.map { |interactor| interactor.new(@context) } + [self] planned.each_with_index do |interactor, i| if i == planned.size - 1 interactor.call_self else interactor.call_all end break if @context.stopped? end end |
#call_self ⇒ Object
31 32 33 34 35 |
# File 'lib/ii_interactor/core.rb', line 31 def call_self call.tap do @context._called << self end end |
#fail!(data = {}) ⇒ Object
47 48 49 50 |
# File 'lib/ii_interactor/core.rb', line 47 def fail!(data = {}) @context.fail!(data) raise UnprogressableError.new(@context) end |
#inform(*args) ⇒ Object
43 44 45 |
# File 'lib/ii_interactor/core.rb', line 43 def inform(*args) @context._block.call(*([self] + args)) if @context._block end |
#initialize(context = {}, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/ii_interactor/core.rb', line 11 def initialize(context = {}, &block) @context = if context.is_a?(IIInteractor::Context) context else IIInteractor::Context.new(context, &block) end end |
#rollback ⇒ Object
40 41 |
# File 'lib/ii_interactor/core.rb', line 40 def rollback end |
#stop!(data = {}) ⇒ Object
52 53 54 |
# File 'lib/ii_interactor/core.rb', line 52 def stop!(data = {}) @context.stop!(data) end |