Class: FunctionalLightService::Sequencer::Sequencer
- Defined in:
- lib/functional-light-service/functional/sequencer.rb
Instance Method Summary collapse
- #and_then(&block) ⇒ Object
- #and_yield(&block) ⇒ Object
- #get(name, &block) ⇒ Object
-
#initialize(instance) ⇒ Sequencer
constructor
A new instance of Sequencer.
- #let(name, &block) ⇒ Object
- #observe(&block) ⇒ Object
- #yield ⇒ Object
Constructor Details
#initialize(instance) ⇒ Sequencer
Returns a new instance of Sequencer.
36 37 38 39 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 36 def initialize(instance) @operations = [] @operation_wrapper = OperationWrapper.new(instance) end |
Instance Method Details
#and_then(&block) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 55 def and_then(&block) raise ArgumentError, 'no block given' unless block_given? raise InvalidSequenceError, 'and_yield already called' if @sequenced_operations @operations << Operation::AndThen.new(block) end |
#and_yield(&block) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 69 def and_yield(&block) raise ArgumentError, 'no block given' unless block_given? raise InvalidSequenceError, 'and_yield already called' if @sequenced_operations @operations << Operation::AndYield.new(block) prepare_sequenced_operations end |
#get(name, &block) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 41 def get(name, &block) raise ArgumentError, 'no block given' unless block_given? raise InvalidSequenceError, 'and_yield already called' if @sequenced_operations @operations << Operation::Get.new(block, name) end |
#let(name, &block) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 48 def let(name, &block) raise ArgumentError, 'no block given' unless block_given? raise InvalidSequenceError, 'and_yield already called' if @sequenced_operations @operations << Operation::Let.new(block, name) end |
#observe(&block) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 62 def observe(&block) raise ArgumentError, 'no block given' unless block_given? raise InvalidSequenceError, 'and_yield already called' if @sequenced_operations @operations << Operation::Observe.new(block) end |
#yield ⇒ Object
78 79 80 81 82 |
# File 'lib/functional-light-service/functional/sequencer.rb', line 78 def yield raise InvalidSequenceError, 'and_yield not called' unless @sequenced_operations @operation_wrapper.instance_eval(&@sequenced_operations) end |