Sha256: cdf2f28155f47da391a80a3b4eed21d32b2325b06e7b5c1c1c54731cd7ad60ef

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

# External dependencies
require 'multi_json'

# No internal dependencies
require 'torm/version'
require 'torm/tools'

# This is where the magic happens
require 'torm/rules_engine'

module Torm
  class << self
    include Tools

    attr_accessor :instance, :default_rules_file

    # @return [Torm::RulesEngine] Singleton RulesEngine
    def instance
      @instance ||= RulesEngine.load || RulesEngine.new
    end

    # @return [String] Path where the default rules can be stored
    def default_rules_file
      @default_rules_file ||= File.expand_path('tmp/rules.json')
    end

    # Load an engine with the current rules, yield it (to add rules) and then save it if rules were added.
    #
    # @yield [Torm::RulesEngine]
    def set_defaults(engine: instance)
      yield engine
      engine.save if engine.dirty?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
torm-0.2.1 lib/torm.rb
torm-0.2.0 lib/torm.rb
torm-0.1.0 lib/torm.rb