Class: RulesEngine::Rule::Definition
- Inherits:
-
Object
- Object
- RulesEngine::Rule::Definition
- 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
-
#attributes=(params) ⇒ Object
set the rule attributes.
-
#before_create ⇒ Object
callbacks when the rule is added and removed from a workflow.
- #before_destroy ⇒ Object
- #before_update ⇒ Object
- #data ⇒ Object
-
#data=(data) ⇒ Object
set the rule data.
- #errors ⇒ Object
- #expected_outcomes ⇒ Object
-
#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.
- #summary ⇒ Object
-
#title ⇒ Object
get the rule attributes.
-
#valid? ⇒ Boolean
validation and errors.
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_create ⇒ Object
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_destroy ⇒ Object
72 73 |
# File 'lib/rules_engine/rule/definition.rb', line 72 def before_destroy() end |
#before_update ⇒ Object
69 70 |
# File 'lib/rules_engine/rule/definition.rb', line 69 def before_update() end |
#data ⇒ Object
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 |
#errors ⇒ Object
59 60 61 62 |
# File 'lib/rules_engine/rule/definition.rb', line 59 def errors @errors ||= {} return @errors end |
#expected_outcomes ⇒ Object
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 |
#summary ⇒ Object
36 37 38 |
# File 'lib/rules_engine/rule/definition.rb', line 36 def summary return nil end |
#title ⇒ Object
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
55 56 57 |
# File 'lib/rules_engine/rule/definition.rb', line 55 def valid? true end |