Class: RulesEngine::Rule::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/rules_engine/rule/definition.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(base) ⇒ Object



4
5
6
# File 'lib/rules_engine/rule/definition.rb', line 4

def self.inherited(base)
  base.extend(ClassMethods) 
end

Instance Method Details

#attributes=(params) ⇒ Object

set the rule attributes



45
46
# File 'lib/rules_engine/rule/definition.rb', line 45

def attributes=(params)
end

#before_createObject

callbacks when the rule is added and removed from a workflow



61
62
# File 'lib/rules_engine/rule/definition.rb', line 61

def before_create()
end

#before_destroyObject



67
68
# File 'lib/rules_engine/rule/definition.rb', line 67

def before_destroy()
end

#before_updateObject



64
65
# File 'lib/rules_engine/rule/definition.rb', line 64

def before_update()
end

#dataObject



35
36
37
# File 'lib/rules_engine/rule/definition.rb', line 35

def data
  return nil
end

#data=(data) ⇒ Object

set the rule data



22
23
# File 'lib/rules_engine/rule/definition.rb', line 22

def data= data      
end

#errorsObject



54
55
56
57
# File 'lib/rules_engine/rule/definition.rb', line 54

def errors
  @errors ||= {}
  return @errors
end

#expected_outcomesObject



39
40
41
# File 'lib/rules_engine/rule/definition.rb', line 39

def expected_outcomes
  [:outcome => RulesEngine::Rule::Outcome::NEXT]
end

#optionsObject



16
17
18
# File 'lib/rules_engine/rule/definition.rb', line 16

def options
  self.class.options
end

#process(process_id, plan, data) ⇒ Object

execute the rule return an RulesEngine::Rule::Outcome object to define what to do next if nil to continue to the next rule



74
75
76
77
78
79
80
# File 'lib/rules_engine/rule/definition.rb', line 74

def process(process_id, plan, data)
  # process.audit("process #{title}", RulesEngine::Process::AUDIT_INFO)                        
  # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_SUCCESS)
  # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_FAILURE)
  # RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::START_WORKFLOW, 'next_workflow')
  RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::NEXT)
end

#summaryObject



31
32
33
# File 'lib/rules_engine/rule/definition.rb', line 31

def summary
  return nil
end

#titleObject

get the rule attributes



27
28
29
# File 'lib/rules_engine/rule/definition.rb', line 27

def title
  return nil
end

#valid?Boolean

validation and errors

Returns:

  • (Boolean)


50
51
52
# File 'lib/rules_engine/rule/definition.rb', line 50

def valid?
  true
end