Class: RulesEngine::Rule::Definition

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

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

@@options =
{
  # :group          => "The group the rule belongs to",
  # :display_name   => "name to use on forms and views",
  # :help_partial   => "the help html.erb template",
  # :new_partial    => "the new html.erb template",
  # :edit_partial   => "the edit html.erb template"
}

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



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

def attributes=(params)
end

#before_createObject

callbacks when the rule is added and removed from a workflow



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

def before_create()
end

#before_destroyObject



72
73
# File 'lib/rules_engine/rule/definition.rb', line 72

def before_destroy()
end

#before_updateObject



69
70
# File 'lib/rules_engine/rule/definition.rb', line 69

def before_update()
end

#dataObject



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

def data
  return nil
end

#data=(data) ⇒ Object

set the rule data



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

def data= data      
end

#errorsObject



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

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

#expected_outcomesObject



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

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

#process(process_id, 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



79
80
81
82
83
84
85
# File 'lib/rules_engine/rule/definition.rb', line 79

def process(process_id, 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



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

def summary
  return nil
end

#titleObject

get the rule attributes



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

def title
  return nil
end

#valid?Boolean

validation and errors

Returns:

  • (Boolean)


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

def valid?
  true
end