Class: Ni::ActionChain
- Inherits:
-
Object
- Object
- Ni::ActionChain
- Defined in:
- lib/ni/action_chain.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#failure_callback ⇒ Object
Returns the value of attribute failure_callback.
-
#name ⇒ Object
Returns the value of attribute name.
-
#received_values ⇒ Object
Returns the value of attribute received_values.
-
#rescues ⇒ Object
Returns the value of attribute rescues.
-
#returned_values ⇒ Object
Returns the value of attribute returned_values.
-
#units ⇒ Object
Returns the value of attribute units.
Instance Method Summary collapse
- #branch(*args, **options, &block) ⇒ Object
- #cancel! ⇒ Object
- #failure(&block) ⇒ Object
- #failure! ⇒ Object
-
#initialize(klass, name, description, &block) ⇒ ActionChain
constructor
A new instance of ActionChain.
- #isolate(*args, **options, &block) ⇒ Object
- #provide(*args) ⇒ Object
-
#receive(*args) ⇒ Object
Params methods.
- #rescue_from(*args, &block) ⇒ Object
- #success! ⇒ Object
- #terminate! ⇒ Object
-
#then(*args, **options, &block) ⇒ Object
Flow methods.
- #wait_for(condition, options = {}) ⇒ Object
Constructor Details
#initialize(klass, name, description, &block) ⇒ ActionChain
Returns a new instance of ActionChain.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ni/action_chain.rb', line 5 def initialize(klass, name, description, &block) @interactor_klass = klass @name = name, @description = description @units = block_given? ? [block.to_proc] : [] @failure_callback = nil @rescues = [] @returned_values = [] self ensure update_chain end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def description @description end |
#failure_callback ⇒ Object
Returns the value of attribute failure_callback.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def failure_callback @failure_callback end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def name @name end |
#received_values ⇒ Object
Returns the value of attribute received_values.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def received_values @received_values end |
#rescues ⇒ Object
Returns the value of attribute rescues.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def rescues @rescues end |
#returned_values ⇒ Object
Returns the value of attribute returned_values.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def returned_values @returned_values end |
#units ⇒ Object
Returns the value of attribute units.
3 4 5 |
# File 'lib/ni/action_chain.rb', line 3 def units @units end |
Instance Method Details
#branch(*args, **options, &block) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/ni/action_chain.rb', line 89 def branch(*args, **, &block) @units << Ni::Flows::BranchInteractor.new(@interactor_klass, args, , &block) self ensure update_chain end |
#cancel! ⇒ Object
103 104 105 106 107 |
# File 'lib/ni/action_chain.rb', line 103 def cancel! @units << "context.cancel!" ensure update_chain end |
#failure(&block) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/ni/action_chain.rb', line 63 def failure(&block) @failure_callback = block.to_proc self ensure update_chain end |
#failure! ⇒ Object
109 110 111 112 113 |
# File 'lib/ni/action_chain.rb', line 109 def failure! @units << "context.failure!" ensure update_chain end |
#isolate(*args, **options, &block) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ni/action_chain.rb', line 50 def isolate(*args, **, &block) if block_given? raise 'Not Implemented yet' else first, last = args @units << Ni::Flows::IsolatedInlineInteractor.new(first, (last || :perform), ) end self ensure update_chain end |
#provide(*args) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ni/action_chain.rb', line 28 def provide(*args) @returned_values = args self ensure update_chain end |
#receive(*args) ⇒ Object
Params methods
20 21 22 23 24 25 26 |
# File 'lib/ni/action_chain.rb', line 20 def receive(*args) @received_values = args self ensure update_chain end |
#rescue_from(*args, &block) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/ni/action_chain.rb', line 71 def rescue_from(*args, &block) args = [Exception] if args.empty? @rescues << [args, block.to_proc] self ensure update_chain end |
#success! ⇒ Object
115 116 117 118 119 |
# File 'lib/ni/action_chain.rb', line 115 def success! @units << "context.success!" ensure update_chain end |
#terminate! ⇒ Object
97 98 99 100 101 |
# File 'lib/ni/action_chain.rb', line 97 def terminate! @units << "context.terminate!" ensure update_chain end |
#then(*args, **options, &block) ⇒ Object
Flow methods
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ni/action_chain.rb', line 38 def then(*args, **, &block) if block_given? @units << block.to_proc else @units << chain_builder(args, ) end self ensure update_chain end |
#wait_for(condition, options = {}) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/ni/action_chain.rb', line 81 def wait_for(condition, ={}) @units << Ni::Flows::WaitForCondition.new(condition, @interactor_klass, ) self ensure update_chain end |