Class: Roast::SystemCogs::Call::Input
- Inherits:
-
Cog::Input
- Object
- Cog::Input
- Roast::SystemCogs::Call::Input
- Defined in:
- lib/roast/system_cogs/call.rb
Overview
Input for the call system cog
Provides the value and index to be passed to the execution scope. The scope can access these through the implicit variables available in the execution context.
Instance Attribute Summary collapse
-
#index ⇒ Object
The index value to pass to the execution scope.
-
#value ⇒ Object
The value to pass to the execution scope.
Instance Method Summary collapse
-
#coerce(input_return_value) ⇒ Object
Coerce the input from the return value of the input block.
-
#initialize ⇒ Input
constructor
: () -> void.
-
#validate! ⇒ Object
Validate that required input values are present.
Constructor Details
#initialize ⇒ Input
: () -> void
49 50 51 52 |
# File 'lib/roast/system_cogs/call.rb', line 49 def initialize super @index = 0 end |
Instance Attribute Details
#index ⇒ Object
The index value to pass to the execution scope
Defaults to 0. Can be used to track position when calling scopes in a sequence.
Integer
46 47 48 |
# File 'lib/roast/system_cogs/call.rb', line 46 def index @index end |
#value ⇒ Object
The value to pass to the execution scope
This value becomes available in the called scope and can be accessed by steps within that scope. Required.
: untyped
39 40 41 |
# File 'lib/roast/system_cogs/call.rb', line 39 def value @value end |
Instance Method Details
#coerce(input_return_value) ⇒ Object
Coerce the input from the return value of the input block
Sets the value from the input block’s return value if not already set directly.
65 66 67 68 |
# File 'lib/roast/system_cogs/call.rb', line 65 def coerce(input_return_value) super @value = input_return_value unless @value.present? end |
#validate! ⇒ Object
Validate that required input values are present
: () -> void
57 58 59 |
# File 'lib/roast/system_cogs/call.rb', line 57 def validate! raise Cog::Input::InvalidInputError, "'value' is required" if value.nil? && !coerce_ran? end |