Class: Julewire::Core::Execution::ScopeFields
- Inherits:
-
Object
- Object
- Julewire::Core::Execution::ScopeFields
- Defined in:
- lib/julewire/core/execution/scope_fields.rb
Instance Attribute Summary collapse
-
#stacks ⇒ Object
readonly
Returns the value of attribute stacks.
Instance Method Summary collapse
- #add(section, fields, owned: false) ⇒ Object
- #attributes_hash ⇒ Object
- #carry_hash ⇒ Object
- #context_hash ⇒ Object
- #delete(section, path) ⇒ Object
- #field_hash(section) ⇒ Object
- #field_stack(section) ⇒ Object
- #frozen_labels_hash ⇒ Object
-
#initialize(context:, attributes:, labels:, carry:, neutral:) ⇒ ScopeFields
constructor
A new instance of ScopeFields.
- #labels_hash ⇒ Object
- #neutral_hash ⇒ Object
- #with(section, fields, owned: false) ⇒ Object
- #without(section, path) ⇒ Object
Constructor Details
#initialize(context:, attributes:, labels:, carry:, neutral:) ⇒ ScopeFields
Returns a new instance of ScopeFields.
12 13 14 15 16 17 18 19 20 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 12 def initialize(context:, attributes:, labels:, carry:, neutral:) @stacks = Fields::StackSet.new( context: context, carry: carry, attributes: attributes, neutral: neutral ) @labels = normalized_static_hash(labels) end |
Instance Attribute Details
#stacks ⇒ Object (readonly)
Returns the value of attribute stacks.
10 11 12 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 10 def stacks @stacks end |
Instance Method Details
#add(section, fields, owned: false) ⇒ Object
50 51 52 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 50 def add(section, fields, owned: false) @stacks.add(section, fields, owned: owned) end |
#attributes_hash ⇒ Object
26 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 26 def attributes_hash = @stacks.snapshot(:attributes) |
#carry_hash ⇒ Object
24 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 24 def carry_hash = @stacks.snapshot(:carry) |
#context_hash ⇒ Object
22 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 22 def context_hash = @stacks.snapshot(:context) |
#delete(section, path) ⇒ Object
54 55 56 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 54 def delete(section, path) @stacks.delete(section, path) end |
#field_hash(section) ⇒ Object
30 31 32 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 30 def field_hash(section) @stacks.snapshot(section) end |
#field_stack(section) ⇒ Object
34 35 36 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 34 def field_stack(section) @stacks.stack(section) end |
#frozen_labels_hash ⇒ Object
44 45 46 47 48 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 44 def frozen_labels_hash return EMPTY_HASH if @labels.empty? @frozen_labels_hash ||= Fields::Internal.frozen_copy(@labels) end |
#labels_hash ⇒ Object
38 39 40 41 42 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 38 def labels_hash return {} if @labels.empty? Fields::FieldSet.deep_dup(@labels) end |
#neutral_hash ⇒ Object
28 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 28 def neutral_hash = @stacks.snapshot(:neutral) |
#with(section, fields, owned: false) ⇒ Object
58 59 60 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 58 def with(section, fields, owned: false, &) @stacks.with(section, fields, owned: owned, &) end |
#without(section, path) ⇒ Object
62 63 64 |
# File 'lib/julewire/core/execution/scope_fields.rb', line 62 def without(section, path, &) @stacks.without(section, path, &) end |