Class: RulesEngine::Rule
- Inherits:
-
Object
- Object
- RulesEngine::Rule
- Defined in:
- lib/rules_engine/rule.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
-
#after_add_to_pipeline(re_pipeline_id, re_rule_id) ⇒ Object
callbacks when the rule is added and removed from a pipeline.
-
#attributes=(params) ⇒ Object
set the rule attributes.
- #before_remove_from_pipeline(re_pipeline_id, re_rule_id) ⇒ Object
- #data ⇒ Object
-
#data=(data) ⇒ Object
set the rule data.
- #errors ⇒ Object
- #expected_outcomes ⇒ Object
-
#process(job, data) ⇒ Object
execute the rule return an RulesEngine::RuleOutcome 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
3 4 5 |
# File 'lib/rules_engine/rule.rb', line 3 def self.inherited(base) base.extend(ClassMethods) end |
Instance Method Details
#after_add_to_pipeline(re_pipeline_id, re_rule_id) ⇒ Object
callbacks when the rule is added and removed from a pipeline
65 66 |
# File 'lib/rules_engine/rule.rb', line 65 def after_add_to_pipeline(re_pipeline_id, re_rule_id) end |
#attributes=(params) ⇒ Object
set the rule attributes
49 50 |
# File 'lib/rules_engine/rule.rb', line 49 def attributes=(params) end |
#before_remove_from_pipeline(re_pipeline_id, re_rule_id) ⇒ Object
68 69 |
# File 'lib/rules_engine/rule.rb', line 68 def before_remove_from_pipeline(re_pipeline_id, re_rule_id) end |
#data ⇒ Object
39 40 41 |
# File 'lib/rules_engine/rule.rb', line 39 def data return nil end |
#data=(data) ⇒ Object
set the rule data
26 27 |
# File 'lib/rules_engine/rule.rb', line 26 def data= data end |
#errors ⇒ Object
58 59 60 61 |
# File 'lib/rules_engine/rule.rb', line 58 def errors @errors ||= {} return @errors end |
#expected_outcomes ⇒ Object
43 44 45 |
# File 'lib/rules_engine/rule.rb', line 43 def expected_outcomes [:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT] end |
#process(job, data) ⇒ Object
execute the rule return an RulesEngine::RuleOutcome object to define what to do next if nil to continue to the next rule
75 76 77 78 79 80 81 |
# File 'lib/rules_engine/rule.rb', line 75 def process(job, data) job.audit("process #{title}", ReJobAudit::AUDIT_INFO) # RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS) # RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE) # RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE, 'next_pipeline') RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_NEXT) end |
#summary ⇒ Object
35 36 37 |
# File 'lib/rules_engine/rule.rb', line 35 def summary return nil end |
#title ⇒ Object
get the rule attributes
31 32 33 |
# File 'lib/rules_engine/rule.rb', line 31 def title return nil end |
#valid? ⇒ Boolean
validation and errors
54 55 56 |
# File 'lib/rules_engine/rule.rb', line 54 def valid? true end |