Class: Solid::Output

Inherits:
Result show all
Defined in:
lib/solid/output/mixin.rb,
lib/solid/output/success.rb,
lib/solid/output/expectations.rb,
lib/solid/output/expectations/mixin.rb,
lib/solid/output.rb

Direct Known Subclasses

Failure, Success

Defined Under Namespace

Modules: CallableAndThen, Mixin Classes: Error, Expectations, Failure, Success

Constant Summary collapse

EXPECTED_OUTCOME =
'Solid::Output::Success or Solid::Output::Failure'

Constants inherited from Result

Result::TYPE_AND_VALUE, Result::VERSION

Instance Attribute Summary

Attributes inherited from Result

#data, #event_logs, #terminal

Class Method Summary collapse

Instance Method Summary collapse

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) ⇒ Output

Returns a new instance of Output.



20
21
22
23
24
25
26
# File 'lib/solid/output.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'

  @memo = {}

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Solid::Result

Class Method Details

.Failure(type, **value) ⇒ Object



16
17
18
# File 'lib/solid/output.rb', line 16

def self.Failure(type, **value)
  Failure.new(type: type, value: value)
end

.Success(type, **value) ⇒ Object



12
13
14
# File 'lib/solid/output.rb', line 12

def self.Success(type, **value)
  Success.new(type: type, value: value)
end

Instance Method Details

#[](key) ⇒ Object



40
41
42
# File 'lib/solid/output.rb', line 40

def [](key)
  value[key]
end

#and_then(method_name = nil, **injected_value, &block) ⇒ Object



28
29
30
# File 'lib/solid/output.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/solid/output.rb', line 32

def and_then!(source, **injected_value)
  _call = injected_value.delete(:_call)

  memo.merge!(injected_value)

  super(source, injected_value, _call: _call)
end

#digObject



44
45
46
# File 'lib/solid/output.rb', line 44

def dig(...)
  value.dig(...)
end

#fetchObject



48
49
50
# File 'lib/solid/output.rb', line 48

def fetch(...)
  value.fetch(...)
end

#fetch_valuesObject



60
61
62
# File 'lib/solid/output.rb', line 60

def fetch_values(...)
  value.fetch_values(...)
end

#sliceObject



52
53
54
# File 'lib/solid/output.rb', line 52

def slice(...)
  value.slice(...)
end

#values_atObject



56
57
58
# File 'lib/solid/output.rb', line 56

def values_at(...)
  value.values_at(...)
end