Class: Julewire::Core::Execution::ScopeFields

Inherits:
Object
  • Object
show all
Defined in:
lib/julewire/core/execution/scope_fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stacksObject (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_hashObject



26
# File 'lib/julewire/core/execution/scope_fields.rb', line 26

def attributes_hash = @stacks.snapshot(:attributes)

#carry_hashObject



24
# File 'lib/julewire/core/execution/scope_fields.rb', line 24

def carry_hash = @stacks.snapshot(:carry)

#context_hashObject



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_hashObject



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_hashObject



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_hashObject



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