Sha256: ee9ea9c4914c880fbf2e919bb9c676c84ce137b0ea303e8c28439546138bed18

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require "bigdecimal"
require "dentaku/calculator"
require "dentaku/version"

module Dentaku
  @enable_ast_caching = false
  @enable_dependency_order_caching = false
  @aliases = {}

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

  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

  def self.aliases
    @aliases
  end

  def self.aliases=(hash)
    @aliases = hash
  end

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dentaku-3.3.4 lib/dentaku.rb
dentaku-3.3.3 lib/dentaku.rb
dentaku-3.3.2 lib/dentaku.rb