Class: Ruby::Rego::WithModifiers::WithModifierRootScope
- Inherits:
-
Object
- Object
- Ruby::Rego::WithModifiers::WithModifierRootScope
- Defined in:
- lib/ruby/rego/with_modifiers/with_modifier_root_scope.rb
Overview
Encapsulates input/data root access for with modifiers.
Constant Summary collapse
- ROOT_NAMES =
%w[input data].freeze
Instance Method Summary collapse
-
#base_value ⇒ Object
-
#initialize(environment:, name:, location: nil) ⇒ WithModifierRootScope
constructor
A new instance of WithModifierRootScope.
-
#with_override(overridden) {|environment| ... } ⇒ Object
Constructor Details
#initialize(environment:, name:, location: nil) ⇒ WithModifierRootScope
Returns a new instance of WithModifierRootScope.
15 16 17 18 19 20 |
# File 'lib/ruby/rego/with_modifiers/with_modifier_root_scope.rb', line 15 def initialize(environment:, name:, location: nil) @environment = environment @name = name @location = location validate_name end |
Instance Method Details
#base_value ⇒ Object
23 24 25 |
# File 'lib/ruby/rego/with_modifiers/with_modifier_root_scope.rb', line 23 def base_value input_scope? ? environment.input.to_ruby : environment.data.to_ruby end |
#with_override(overridden) {|environment| ... } ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/ruby/rego/with_modifiers/with_modifier_root_scope.rb', line 30 def with_override(overridden, &) if input_scope? environment.with_overrides(input: overridden, &) else environment.with_overrides(data: overridden, &) end end |