Class: Chartnado::Evaluator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/chartnado/evaluator.rb

Defined Under Namespace

Modules: Operators Classes: OperatorEvaluator

Class Method Summary collapse

Class Method Details

.with_operators(&block) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/chartnado/evaluator.rb', line 69

def self.with_operators(&block)
  original_value = Thread.current[:in_chartnado_block]
  binding = eval 'self', block.binding
  Thread.current[:in_chartnado_block] = true
  Evaluator.new(binding).instance_eval(&block)
ensure
  Thread.current[:in_chartnado_block] = original_value
end

.without_operatorsObject



61
62
63
64
65
66
67
# File 'lib/chartnado/evaluator.rb', line 61

def self.without_operators
  in_chartnado_block = Thread.current[:in_chartnado_block]
  Thread.current[:in_chartnado_block] = nil
  yield
ensure
  Thread.current[:in_chartnado_block] = in_chartnado_block
end