Class: Datadog::DI::EL::Expression Private

Inherits:
Object
  • Object
show all
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.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

API:

  • private



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("      def evaluate(context)\n        @context = context\n        \#{compiled_expr}\n      end\n    RUBY\n  end\n  @evaluator = cls.new\nend\n", Object.new.send(:binding), __FILE__, __LINE__ + 1) # standard:disable Security/Eval

Instance Attribute Details

#dsl_exprObject (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.

API:

  • private



29
30
31
# File 'lib/datadog/di/el/expression.rb', line 29

def dsl_expr
  @dsl_expr
end

#evaluatorObject (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.

API:

  • private



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.

API:

  • private



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.

Returns:

API:

  • private



36
37
38
# File 'lib/datadog/di/el/expression.rb', line 36

def satisfied?(context)
  !!evaluate(context)
end