Class: Solid::Output::Success
- Inherits:
-
Solid::Output
- Object
- Result
- Solid::Output
- Solid::Output::Success
- Includes:
- Success
- Defined in:
- lib/solid/output/success.rb
Constant Summary collapse
- FetchValues =
->(memo_values, keys) do fetched_values = memo_values.fetch_values(*keys) keys.zip(fetched_values).to_h rescue ::KeyError => e = "#{e.}. Available to expose: #{memo_values.keys.map(&:inspect).join(', ')}" raise Error::InvalidExposure, end
Constants inherited from Solid::Output
Constants inherited from Result
Result::TYPE_AND_VALUE, Result::VERSION
Instance Attribute Summary
Attributes inherited from Result
Instance Method Summary collapse
Methods included from Success
#failure?, #success?, #value_or
Methods inherited from Solid::Output
Failure, Success, #[], #and_then, #and_then!, #dig, #fetch, #fetch_values, #initialize, #slice, #values_at
Methods inherited from Result
#==, Failure, Success, #and_then, #and_then!, config, configuration, #deconstruct, #deconstruct_keys, event_logs, #failure?, #handle, #hash, #initialize, #inspect, #method_missing, mixin, #on, #on_failure, #on_success, #on_unknown, #respond_to_missing?, #success?, #terminal?, #type, #type?, #value, #value_or
Constructor Details
This class inherits a constructor from Solid::Output
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Solid::Result
Instance Method Details
#and_expose(type, keys, terminal: true) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/solid/output/success.rb', line 21 def and_expose(type, keys, terminal: true) unless keys.is_a?(::Array) && !keys.empty? && keys.all?(::Symbol) raise ::ArgumentError, 'keys must be an Array of Symbols' end EventLogs.tracking.reset_and_then! memo_values = memo.merge(value) value_to_expose = FetchValues.call(memo_values, keys) expectations = type_checker.expectations self.class.new(type: type, value: value_to_expose, source: source, terminal: terminal, expectations: expectations) end |