Class: Datadog::DI::EL::Expression Private
- Inherits:
-
Object
- Object
- Datadog::DI::EL::Expression
- Defined in:
- lib/datadog/di/el/expression.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents an Expression Language expression.
Instance Attribute Summary collapse
- #dsl_expr ⇒ Object readonly private
- #evaluator ⇒ Object readonly private
- #redaction_identifier ⇒ Object readonly private
Instance Method Summary collapse
- #evaluate(context) ⇒ Object private
-
#initialize(dsl_expr, compiled_expr, regexps: [], redaction_identifier: nil) ⇒ Expression
constructor
private
A new instance of Expression.
- #satisfied?(context) ⇒ Boolean private
Constructor Details
#initialize(dsl_expr, compiled_expr, regexps: [], redaction_identifier: nil) ⇒ Expression
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Expression.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/datadog/di/el/expression.rb', line 19 def initialize(dsl_expr, compiled_expr, regexps: [], redaction_identifier: nil) unless String === compiled_expr raise ArgumentError, "compiled_expr must be a string" end @dsl_expr = dsl_expr @redaction_identifier = redaction_identifier cls = Class.new(Evaluator) cls.class_exec do eval(<<-RUBY, Object.new.send(:binding), __FILE__, __LINE__ + 1) # standard:disable Security/Eval def evaluate(context) @context = context #{compiled_expr} end RUBY end @evaluator = cls.new(regexps) end |
Instance Attribute Details
#dsl_expr ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/datadog/di/el/expression.rb', line 39 def dsl_expr @dsl_expr end |
#evaluator ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/datadog/di/el/expression.rb', line 40 def evaluator @evaluator end |
#redaction_identifier ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/datadog/di/el/expression.rb', line 41 def redaction_identifier @redaction_identifier end |
Instance Method Details
#evaluate(context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/datadog/di/el/expression.rb', line 43 def evaluate(context) @evaluator.evaluate(context) end |
#satisfied?(context) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/datadog/di/el/expression.rb', line 47 def satisfied?(context) !!evaluate(context) end |