Class: CEL::Context
- Inherits:
-
Object
- Object
- CEL::Context
- Defined in:
- lib/cel.rb
Class Method Summary collapse
- .__native_new ⇒ Object
- .build(empty: false, **variables) {|ctx| ... } ⇒ Object
- .new(empty = false) ⇒ Object
Instance Method Summary collapse
Class Method Details
.__native_new ⇒ Object
15 |
# File 'lib/cel.rb', line 15 alias_method :__native_new, :new |
.build(empty: false, **variables) {|ctx| ... } ⇒ Object
21 22 23 24 25 26 |
# File 'lib/cel.rb', line 21 def build(empty: false, **variables) ctx = new(empty) variables.each { |k, v| ctx.add_variable(k.to_s, v) } yield(ctx) if block_given? ctx end |
.new(empty = false) ⇒ Object
17 18 19 |
# File 'lib/cel.rb', line 17 def new(empty = false) __native_new(!!empty) end |
Instance Method Details
#define_function(name, &block) ⇒ Object
29 30 31 32 33 |
# File 'lib/cel.rb', line 29 def define_function(name, &block) raise ArgumentError, "block required" unless block add_function(name.to_s, block) end |