Module: Torm

Extended by:
Tools
Defined in:
lib/torm.rb,
lib/torm/version.rb,
lib/torm/rules_engine.rb

Defined Under Namespace

Modules: Tools Classes: RulesEngine

Constant Summary collapse

VERSION =
'0.3.0'

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Tools

atomic_save, slice, symbolize_keys

Class Attribute Details

.default_rules_fileString

Returns Path where the default rules can be stored.

Returns:

  • (String)

    Path where the default rules can be stored



23
24
25
# File 'lib/torm.rb', line 23

def default_rules_file
  @default_rules_file ||= File.expand_path('tmp/rules.json')
end

.instanceTorm::RulesEngine

Returns Singleton RulesEngine.

Returns:



18
19
20
# File 'lib/torm.rb', line 18

def instance
  @instance ||= RulesEngine.load || RulesEngine.new
end

Class Method Details

.set_defaults(engine: instance) {|Torm::RulesEngine| ... } ⇒ Object

Load an engine with the current rules, yield it (to add rules) and then save it if rules were added.

Yields:



30
31
32
33
# File 'lib/torm.rb', line 30

def set_defaults(engine: instance)
  yield engine
  engine.save if engine.dirty?
end