Class: Igniter::Extensions::Contracts::Provenance::NodeTrace
- Inherits:
-
Object
- Object
- Igniter::Extensions::Contracts::Provenance::NodeTrace
- Defined in:
- lib/igniter/extensions/contracts/provenance/node_trace.rb
Instance Attribute Summary collapse
-
#contributing ⇒ Object
readonly
Returns the value of attribute contributing.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #contributing_inputs ⇒ Object
-
#initialize(name:, kind:, value:, contributing: {}) ⇒ NodeTrace
constructor
A new instance of NodeTrace.
- #input? ⇒ Boolean
- #leaf? ⇒ Boolean
- #path_to(input_name) ⇒ Object
- #sensitive_to?(input_name) ⇒ Boolean
Constructor Details
#initialize(name:, kind:, value:, contributing: {}) ⇒ NodeTrace
Returns a new instance of NodeTrace.
10 11 12 13 14 15 16 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 10 def initialize(name:, kind:, value:, contributing: {}) @name = name.to_sym @kind = kind.to_sym @value = value @contributing = contributing.freeze freeze end |
Instance Attribute Details
#contributing ⇒ Object (readonly)
Returns the value of attribute contributing.
8 9 10 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 8 def contributing @contributing end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
8 9 10 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 8 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 8 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 8 def value @value end |
Instance Method Details
#contributing_inputs ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 26 def contributing_inputs return { name => value } if input? contributing.each_value.with_object({}) do |trace, memo| memo.merge!(trace.contributing_inputs) end end |
#input? ⇒ Boolean
18 19 20 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 18 def input? kind == :input end |
#leaf? ⇒ Boolean
22 23 24 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 22 def leaf? contributing.empty? end |
#path_to(input_name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 38 def path_to(input_name) target = input_name.to_sym return [name] if name == target contributing.each_value do |trace| path = trace.path_to(target) return [name] + path if path end nil end |
#sensitive_to?(input_name) ⇒ Boolean
34 35 36 |
# File 'lib/igniter/extensions/contracts/provenance/node_trace.rb', line 34 def sensitive_to?(input_name) contributing_inputs.key?(input_name.to_sym) end |