Class: Julewire::Core::Execution::Lineage
- Inherits:
-
Object
- Object
- Julewire::Core::Execution::Lineage
- Defined in:
- lib/julewire/core/execution/lineage.rb
Constant Summary collapse
- MAX_ANCESTORS =
Bounded to cap summary growth; also the Answer to the Ultimate Question.
42- RELATIONSHIP_KEYS =
%i[depth root parent ancestors ancestors_truncated].freeze
- LAZY_RELATIONSHIP_KEYS =
%i[ancestors ancestors_truncated].freeze
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#parent_reference ⇒ Object
readonly
Returns the value of attribute parent_reference.
-
#root_reference ⇒ Object
readonly
Returns the value of attribute root_reference.
Class Method Summary collapse
- .clean_execution_hash(execution) ⇒ Object
- .clean_lazy_relationship_hash(execution) ⇒ Object
- .clean_owned_execution_hash(execution) ⇒ Object
- .from_execution_hash(execution) ⇒ Object
Instance Method Summary collapse
- #ancestors ⇒ Object
- #freeze ⇒ Object
-
#initialize(reference: nil, parent_lineage: nil, parent_reference: nil, root_reference: nil, depth: nil, ancestors: nil, ancestors_truncated: false) ⇒ Lineage
constructor
A new instance of Lineage.
- #merge_into_frozen(execution) ⇒ Object
- #truncated? ⇒ Boolean
Constructor Details
#initialize(reference: nil, parent_lineage: nil, parent_reference: nil, root_reference: nil, depth: nil, ancestors: nil, ancestors_truncated: false) ⇒ Lineage
Returns a new instance of Lineage.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/julewire/core/execution/lineage.rb', line 70 def initialize( reference: nil, parent_lineage: nil, parent_reference: nil, root_reference: nil, depth: nil, ancestors: nil, ancestors_truncated: false ) @parent_lineage = parent_lineage @depth = depth_value(depth, parent_lineage) @root_reference = freeze_reference(root_reference || root_reference_for(reference, parent_lineage)) @parent_reference = freeze_reference(parent_reference) @ancestor_references = freeze_ancestors(ancestors) @ancestors_truncated = ancestors_truncated ? true : false @ancestor_references_for_child = nil @truncated = nil @truncated_computed = false end |
Instance Attribute Details
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
11 12 13 |
# File 'lib/julewire/core/execution/lineage.rb', line 11 def depth @depth end |
#parent_reference ⇒ Object (readonly)
Returns the value of attribute parent_reference.
11 12 13 |
# File 'lib/julewire/core/execution/lineage.rb', line 11 def parent_reference @parent_reference end |
#root_reference ⇒ Object (readonly)
Returns the value of attribute root_reference.
11 12 13 |
# File 'lib/julewire/core/execution/lineage.rb', line 11 def root_reference @root_reference end |
Class Method Details
.clean_execution_hash(execution) ⇒ Object
14 15 16 |
# File 'lib/julewire/core/execution/lineage.rb', line 14 def clean_execution_hash(execution) clean_hash(execution, RELATIONSHIP_KEYS) end |
.clean_lazy_relationship_hash(execution) ⇒ Object
22 23 24 |
# File 'lib/julewire/core/execution/lineage.rb', line 22 def clean_lazy_relationship_hash(execution) clean_hash(execution, LAZY_RELATIONSHIP_KEYS) end |
.clean_owned_execution_hash(execution) ⇒ Object
18 19 20 |
# File 'lib/julewire/core/execution/lineage.rb', line 18 def clean_owned_execution_hash(execution) clean_hash!(execution, RELATIONSHIP_KEYS) end |
.from_execution_hash(execution) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/julewire/core/execution/lineage.rb', line 26 def from_execution_hash(execution) execution = {} unless execution.is_a?(Hash) new( reference: execution_reference(execution), root_reference: relationship_value(execution, :root), parent_reference: relationship_value(execution, :parent), depth: relationship_value(execution, :depth), ancestors: relationship_value(execution, :ancestors), ancestors_truncated: relationship_value(execution, :ancestors_truncated) ) end |
Instance Method Details
#ancestors ⇒ Object
98 99 100 101 102 103 |
# File 'lib/julewire/core/execution/lineage.rb', line 98 def ancestors references = @ancestor_references_for_child return references if references materialize_ancestor_references_for_child end |
#freeze ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/julewire/core/execution/lineage.rb', line 113 def freeze return self if frozen? ancestors truncated? @parent_lineage = nil super end |
#merge_into_frozen(execution) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/julewire/core/execution/lineage.rb', line 90 def merge_into_frozen(execution) hash = frozen_hash_copy(execution) hash[:depth] = depth hash[:root] = @root_reference hash[:parent] = @parent_reference if @parent_reference hash.freeze end |
#truncated? ⇒ Boolean
105 106 107 108 109 110 111 |
# File 'lib/julewire/core/execution/lineage.rb', line 105 def truncated? return @truncated if @truncated_computed @truncated = @ancestors_truncated || ancestor_count_exceeds_limit? @truncated_computed = true @truncated end |