summaryrefslogtreecommitdiff
path: root/deployment_scripts/puppet/files/embedded/lib/ruby/gems/2.3.0/gems/dentaku-2.0.9/lib/dentaku.rb
blob: 1b081b8d3fd6faa84823cb00a97839cd88e21759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "bigdecimal"
require "dentaku/calculator"
require "dentaku/version"

module Dentaku
  @enable_ast_caching = false
  @enable_dependency_order_caching = false

  def self.evaluate(expression, data={})
    calculator.evaluate(expression, data)
  end

  def self.enable_caching!
    enable_ast_cache!
    enable_dependency_order_cache!
  end

  def self.enable_ast_cache!
    @enable_ast_caching = true
  end

  def self.cache_ast?
    @enable_ast_caching
  end

  def self.enable_dependency_order_cache!
    @enable_dependency_order_caching = true
  end

  def self.cache_dependency_order?
    @enable_dependency_order_caching
  end

  private

  def self.calculator
    @calculator ||= Dentaku::Calculator.new
  end
end

def Dentaku(expression, data={})
  Dentaku.evaluate(expression, data)
end