Class: Igniter::Extensions::Contracts::Dataflow::Result
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Dataflow::Result
- Defined in:
- lib/igniter/extensions/contracts/dataflow/result.rb
Instance Attribute Summary collapse
-
#aggregates ⇒ Object
readonly
Returns the value of attribute aggregates.
-
#diff ⇒ Object
readonly
Returns the value of attribute diff.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#processed ⇒ Object
(also: #collection)
readonly
Returns the value of attribute processed.
Instance Method Summary collapse
- #aggregate(name) ⇒ Object
-
#initialize(processed:, aggregates:, inputs:) ⇒ Result
constructor
A new instance of Result.
- #method_missing(name, *args) ⇒ Object
- #output(name) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #summary ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(processed:, aggregates:, inputs:) ⇒ Result
Returns a new instance of Result.
10 11 12 13 14 15 16 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 10 def initialize(processed:, aggregates:, inputs:) @processed = processed @diff = processed.diff @aggregates = aggregates.transform_keys(&:to_sym).freeze @inputs = inputs freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 43 def method_missing(name, *args) return super unless args.empty? return processed if name.to_sym == :processed return aggregate(name) if aggregates.key?(name.to_sym) super end |
Instance Attribute Details
#aggregates ⇒ Object (readonly)
Returns the value of attribute aggregates.
8 9 10 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 8 def aggregates @aggregates end |
#diff ⇒ Object (readonly)
Returns the value of attribute diff.
8 9 10 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 8 def diff @diff end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
8 9 10 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 8 def inputs @inputs end |
#processed ⇒ Object (readonly) Also known as: collection
Returns the value of attribute processed.
8 9 10 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 8 def processed @processed end |
Instance Method Details
#aggregate(name) ⇒ Object
20 21 22 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 20 def aggregate(name) aggregates.fetch(name.to_sym) end |
#output(name) ⇒ Object
24 25 26 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 24 def output(name) aggregate(name) end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
51 52 53 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 51 def respond_to_missing?(name, include_private = false) name.to_sym == :processed || aggregates.key?(name.to_sym) || super end |
#summary ⇒ Object
28 29 30 31 32 33 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 28 def summary { diff: diff.to_h, aggregates: aggregates } end |
#to_h ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/igniter/extensions/contracts/dataflow/result.rb', line 35 def to_h { processed: processed.to_h, aggregates: aggregates, inputs: inputs.to_h } end |