Class: Ruby::Rego::WithModifiers::WithModifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/rego/with_modifiers/with_modifier.rb

Overview

Applies with modifiers to a temporary environment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target:, value:) ⇒ WithModifier

Returns a new instance of WithModifier.

Parameters:

  • target (Object)
  • value (Object)


12
13
14
15
# File 'lib/ruby/rego/with_modifiers/with_modifier.rb', line 12

def initialize(target:, value:)
  @target = target
  @value = value
end

Instance Attribute Details

#targetObject (readonly)

Returns:

  • (Object)


18
19
20
# File 'lib/ruby/rego/with_modifiers/with_modifier.rb', line 18

def target
  @target
end

#valueObject (readonly)

Returns:

  • (Object)


21
22
23
# File 'lib/ruby/rego/with_modifiers/with_modifier.rb', line 21

def value
  @value
end

Instance Method Details

#with_environment(environment, expression_evaluator) {|environment| ... } ⇒ Object

Parameters:

Yield Parameters:

Returns:

  • (Object)


27
28
29
30
31
32
33
# File 'lib/ruby/rego/with_modifiers/with_modifier.rb', line 27

def with_environment(environment, expression_evaluator, &)
  WithModifierContext.new(
    modifier: self,
    environment: environment,
    expression_evaluator: expression_evaluator
  ).apply(&)
end