Class: Julewire::Core::Execution::ScopeIdentity
- Inherits:
-
Object
- Object
- Julewire::Core::Execution::ScopeIdentity
- Defined in:
- lib/julewire/core/execution/scope_identity.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lineage ⇒ Object
readonly
Returns the value of attribute lineage.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#started_monotonic ⇒ Object
readonly
Returns the value of attribute started_monotonic.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #depth ⇒ Object
- #execution_fields(execution, owned:) ⇒ Object
- #frozen_execution_hash(execution) ⇒ Object
- #frozen_time(value) ⇒ Object
-
#initialize(type:, id: nil, started_at: nil, parent: nil, parent_reference: nil) ⇒ ScopeIdentity
constructor
A new instance of ScopeIdentity.
Constructor Details
#initialize(type:, id: nil, started_at: nil, parent: nil, parent_reference: nil) ⇒ ScopeIdentity
Returns a new instance of ScopeIdentity.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 11 def initialize(type:, id: nil, started_at: nil, parent: nil, parent_reference: nil) @id = normalize_id(id || SecureRandom.uuid) @type = normalize_type(type) @started_at = frozen_time(started_at || Time.now.utc) @started_monotonic = monotonic_time @parent = parent @reference = { type: @type, id: @id }.freeze @lineage = Lineage.new( reference: @reference, parent_lineage: parent&.lineage, parent_reference: parent_reference ) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def id @id end |
#lineage ⇒ Object (readonly)
Returns the value of attribute lineage.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def lineage @lineage end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def parent @parent end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def reference @reference end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def started_at @started_at end |
#started_monotonic ⇒ Object (readonly)
Returns the value of attribute started_monotonic.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def started_monotonic @started_monotonic end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 9 def type @type end |
Instance Method Details
#depth ⇒ Object
25 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 25 def depth = @lineage.depth |
#execution_fields(execution, owned:) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 27 def execution_fields(execution, owned:) fields = owned ? Lineage.clean_owned_execution_hash(execution) : Lineage.clean_execution_hash(execution) fields[:type] = @type fields[:id] = @id fields end |
#frozen_execution_hash(execution) ⇒ Object
34 35 36 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 34 def frozen_execution_hash(execution) @lineage.merge_into_frozen(execution) end |
#frozen_time(value) ⇒ Object
38 39 40 |
# File 'lib/julewire/core/execution/scope_identity.rb', line 38 def frozen_time(value) Serialization::ValueCopy.call(value, freeze_values: true) end |