Class: BCDD::Context
- Defined in:
- lib/bcdd/context.rb,
lib/bcdd/context/mixin.rb,
lib/bcdd/context/success.rb,
lib/bcdd/context/expectations.rb,
lib/bcdd/context/expectations/mixin.rb
Defined Under Namespace
Modules: CallableAndThen, Mixin Classes: Error, Expectations, Failure, Success
Constant Summary collapse
- EXPECTED_OUTCOME =
'BCDD::Context::Success or BCDD::Context::Failure'
Constants inherited from Result
Result::Context, Result::TYPE_AND_VALUE, Result::VERSION
Instance Attribute Summary
Attributes inherited from Result
Class Method Summary collapse
Instance Method Summary collapse
- #and_then(method_name = nil, **injected_value, &block) ⇒ Object
- #and_then!(source, **injected_value) ⇒ Object
-
#initialize(type:, value:, source: nil, expectations: nil, terminal: nil) ⇒ Context
constructor
A new instance of Context.
Methods inherited from Result
#==, config, configuration, #deconstruct, #deconstruct_keys, event_logs, #failure?, #handle, #hash, #inspect, #method_missing, mixin, #on, #on_failure, #on_success, #on_unknown, #respond_to_missing?, #success?, #terminal?, #type, #type?, #value, #value_or
Constructor Details
#initialize(type:, value:, source: nil, expectations: nil, terminal: nil) ⇒ Context
Returns a new instance of Context.
20 21 22 23 24 25 26 |
# File 'lib/bcdd/context.rb', line 20 def initialize(type:, value:, source: nil, expectations: nil, terminal: nil) value.is_a?(::Hash) or raise ::ArgumentError, 'value must be a Hash' @acc = {} super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BCDD::Result
Class Method Details
Instance Method Details
#and_then(method_name = nil, **injected_value, &block) ⇒ Object
28 29 30 |
# File 'lib/bcdd/context.rb', line 28 def and_then(method_name = nil, **injected_value, &block) super(method_name, injected_value, &block) end |
#and_then!(source, **injected_value) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/bcdd/context.rb', line 32 def and_then!(source, **injected_value) _call = injected_value.delete(:_call) acc.merge!(injected_value) super(source, injected_value, _call: _call) end |