Sha256: aa032bf40d471dd43c8211d4d03c1103ac4e4ed1f1e0ff685269274c67f5f918

Contents?: true

Size: 1007 Bytes

Versions: 2

Compression:

Stored size: 1007 Bytes

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

  private

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dentaku-3.2.0 lib/dentaku.rb
dentaku-3.1.0 lib/dentaku.rb