lib/dentaku.rb in dentaku-3.4.1 vs lib/dentaku.rb in dentaku-3.4.2
- old
+ new
@@ -1,21 +1,22 @@
require "bigdecimal"
+require "concurrent"
require "dentaku/calculator"
require "dentaku/version"
module Dentaku
@enable_ast_caching = false
@enable_dependency_order_caching = false
@enable_identifier_caching = false
@aliases = {}
def self.evaluate(expression, data = {}, &block)
- calculator.evaluate(expression, data, &block)
+ calculator.value.evaluate(expression, data, &block)
end
def self.evaluate!(expression, data = {}, &block)
- calculator.evaluate!(expression, data, &block)
+ calculator.value.evaluate!(expression, data, &block)
end
def self.enable_caching!
enable_ast_cache!
enable_dependency_order_cache!
@@ -53,10 +54,10 @@
def self.aliases=(hash)
@aliases = hash
end
def self.calculator
- @calculator ||= Dentaku::Calculator.new
+ @calculator ||= Concurrent::ThreadLocalVar.new { Dentaku::Calculator.new }
end
end
def Dentaku(expression, data = {})
Dentaku.evaluate(expression, data)