Module: Cel::Extensions::Bind

Defined in:
lib/cel/extensions/bind.rb

Class Method Summary collapse

Class Method Details

.__check(funcall, checker:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cel/extensions/bind.rb', line 12

def __check(funcall, checker:)
  func = funcall.func
  args = funcall.args

  return checker.unsupported_operation(funcall) unless func == :bind

  checker.check_arity(func, args, 3)

  id, type, expr = args

  return checker.unsupported_operation(funcall) unless id.is_a?(Identifier)

  type = checker.call(type)

  checker.environment.with(declarations: { id.to_sym => type }) do
    checker.environment.check(expr)
  end
end

.bind(var, val, expr, program:) ⇒ Object



31
32
33
34
35
# File 'lib/cel/extensions/bind.rb', line 31

def bind(var, val, expr, program:)
  program.environment.with(declarations: { var.to_sym => val.type }, disable_check: false) do
    program.with_extra_context({ var.to_sym => val }).evaluate(expr)
  end
end

.implicit?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/cel/extensions/bind.rb', line 8

def implicit?
  false
end