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
Instance Method Summary collapse
- #evaluate(context) ⇒ Object private
-
#initialize(dsl_expr, compiled_expr) ⇒ Expression
constructor
private
A new instance of Expression.
- #satisfied?(context) ⇒ Boolean private
Constructor Details
#initialize(dsl_expr, compiled_expr) ⇒ 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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/datadog/di/el/expression.rb', line 10 def initialize(dsl_expr, compiled_expr) unless String === compiled_expr raise ArgumentError, "compiled_expr must be a string" end @dsl_expr = dsl_expr 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 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.
29 30 31 |
# File 'lib/datadog/di/el/expression.rb', line 29 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.
30 31 32 |
# File 'lib/datadog/di/el/expression.rb', line 30 def evaluator @evaluator 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.
32 33 34 |
# File 'lib/datadog/di/el/expression.rb', line 32 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.
36 37 38 |
# File 'lib/datadog/di/el/expression.rb', line 36 def satisfied?(context) !!evaluate(context) end |