Class: Noteikumi

Inherits:
Object
  • Object
show all
Defined in:
lib/noteikumi.rb,
lib/noteikumi/rule.rb,
lib/noteikumi/rules.rb,
lib/noteikumi/state.rb,
lib/noteikumi/engine.rb,
lib/noteikumi/result.rb,
lib/noteikumi/version.rb,
lib/noteikumi/rule_execution_scope.rb,
lib/noteikumi/rule_condition_validator.rb

Overview

A light weight rule engine

Visit github.com/ripienaar/noteikumi for more information

Defined Under Namespace

Classes: Engine, Result, Rule, RuleConditionValidator, RuleExecutionScope, Rules, State

Constant Summary collapse

VERSION =
"0.0.1".freeze

Class Method Summary collapse

Class Method Details

.new_engine(path, logger) ⇒ Engine

Helper to create a new Engine

Parameters:

  • path (String)

    a File::PATH_SEPARATOR seperated list of paths to load rules from

  • logger (Logger)

    a logger to use

Returns:



34
35
36
# File 'lib/noteikumi.rb', line 34

def self.new_engine(path, logger)
  Engine.new(path, logger)
end

.rule(rule_name, &blk) ⇒ Rule

Helper to create a new rule from a block

Parameters:

  • rule_name (String, Symbol)

    unique name for this rule, Symbols preferred

  • blk (Proc)

    the rule body with access to methods on Rule

Returns:



21
22
23
24
25
26
27
# File 'lib/noteikumi.rb', line 21

def self.rule(rule_name, &blk)
  rule = Rule.new(rule_name)

  rule.instance_eval(&blk)

  rule
end