Class: SolidFlow::Wait::Context
- Inherits:
-
Object
- Object
- SolidFlow::Wait::Context
- Defined in:
- lib/solid_flow/wait.rb
Instance Attribute Summary collapse
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
Instance Method Summary collapse
- #for(seconds: nil, timestamp: nil, at: nil, metadata: {}) ⇒ Object
- #for_signal(name, metadata: {}) ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
33 34 35 |
# File 'lib/solid_flow/wait.rb', line 33 def initialize @instructions = [] end |
Instance Attribute Details
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
31 32 33 |
# File 'lib/solid_flow/wait.rb', line 31 def instructions @instructions end |
Instance Method Details
#for(seconds: nil, timestamp: nil, at: nil, metadata: {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/solid_flow/wait.rb', line 37 def for(seconds: nil, timestamp: nil, at: nil, metadata: {}) = case when Hash .deep_dup else end = { metadata: } if seconds raise ArgumentError, "seconds must be positive" unless seconds.to_f.positive? [:delay_seconds] = seconds.to_f elsif at || target = at || [:run_at] = target else raise ArgumentError, "wait.for requires :seconds or :timestamp" end instruction = TimerInstruction.new() @instructions << instruction instruction end |
#for_signal(name, metadata: {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/solid_flow/wait.rb', line 62 def for_signal(name, metadata: {}) = case when Hash .deep_dup else end instruction = SignalInstruction.new(signal: name.to_sym, metadata: ) @instructions << instruction instruction end |