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.



9
10
11
12
13
14
15
16
17
# File 'lib/julewire/core/execution/scope_fields.rb', line 9

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.



7
8
9
# File 'lib/julewire/core/execution/scope_fields.rb', line 7

def stacks
  @stacks
end

Instance Method Details

#add(section, fields, owned:) ⇒ Object



43
44
45
# File 'lib/julewire/core/execution/scope_fields.rb', line 43

def add(section, fields, owned:)
  @stacks.add(section, fields, owned: owned)
end

#attributes_hashObject



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

def attributes_hash = @stacks.snapshot(:attributes)

#carry_hashObject



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

def carry_hash = @stacks.snapshot(:carry)

#context_hashObject



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

def context_hash = @stacks.snapshot(:context)

#delete(section, path) ⇒ Object



47
48
49
# File 'lib/julewire/core/execution/scope_fields.rb', line 47

def delete(section, path)
  @stacks.delete(section, path)
end

#field_hash(section) ⇒ Object



27
28
29
# File 'lib/julewire/core/execution/scope_fields.rb', line 27

def field_hash(section)
  @stacks.snapshot(section)
end

#field_stack(section) ⇒ Object



31
32
33
# File 'lib/julewire/core/execution/scope_fields.rb', line 31

def field_stack(section)
  @stacks.stack(section)
end

#frozen_labels_hashObject



39
40
41
# File 'lib/julewire/core/execution/scope_fields.rb', line 39

def frozen_labels_hash
  @frozen_labels_hash ||= Fields::Internal.frozen_copy(@labels)
end

#labels_hashObject



35
36
37
# File 'lib/julewire/core/execution/scope_fields.rb', line 35

def labels_hash
  Fields::FieldSet.deep_dup(@labels)
end

#neutral_hashObject



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

def neutral_hash = @stacks.snapshot(:neutral)

#with(section, fields, owned:, **keyword_fields) ⇒ Object



51
52
53
# File 'lib/julewire/core/execution/scope_fields.rb', line 51

def with(section, fields, owned:, **keyword_fields, &)
  @stacks.with(section, fields, owned: owned, **keyword_fields, &)
end

#without(section, path) ⇒ Object



55
56
57
# File 'lib/julewire/core/execution/scope_fields.rb', line 55

def without(section, path, &)
  @stacks.without(section, path, &)
end