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_normalized_lazy_relationship_hash(execution) ⇒ Object
- .clean_owned_execution_hash(execution) ⇒ Object
- .from_execution_hash(execution) ⇒ Object
Instance Method Summary collapse
- #ancestors ⇒ 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.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/julewire/core/execution/lineage.rb', line 76 def initialize( reference: nil, parent_lineage: nil, parent_reference: nil, root_reference: nil, depth: nil, ancestors: nil, ancestors_truncated: false ) @depth = depth_value(depth, parent_lineage) @root_reference = freeze_reference( root_reference || parent_lineage&.root_reference_for_child || reference ) @parent_reference = freeze_reference(parent_reference) @ancestor_references = freeze_ancestors(ancestors) @ancestors_truncated = ancestors_truncated ? true : false return if @ancestor_references references = inherited_ancestor_references(parent_lineage) @ancestor_references = references.last(MAX_ANCESTORS).freeze @ancestors_truncated ||= references.length > MAX_ANCESTORS 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_normalized_lazy_relationship_hash(execution) ⇒ Object
18 19 20 |
# File 'lib/julewire/core/execution/lineage.rb', line 18 def clean_normalized_lazy_relationship_hash(execution) clean_normalized_hash(execution, LAZY_RELATIONSHIP_KEYS) end |
.clean_owned_execution_hash(execution) ⇒ Object
22 23 24 |
# File 'lib/julewire/core/execution/lineage.rb', line 22 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 |
# File 'lib/julewire/core/execution/lineage.rb', line 26 def from_execution_hash(execution) 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
107 |
# File 'lib/julewire/core/execution/lineage.rb', line 107 def ancestors = @ancestor_references |
#merge_into_frozen(execution) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/julewire/core/execution/lineage.rb', line 99 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
109 |
# File 'lib/julewire/core/execution/lineage.rb', line 109 def truncated? = @ancestors_truncated |