Class: OpenLoam::BusinessRule
- Inherits:
-
TenantRecord
- Object
- TenantRecord
- OpenLoam::BusinessRule
- Includes:
- Auditable
- Defined in:
- app/models/open_loam/business_rule.rb
Overview
A per-tenant, admin-configurable rule: WHEN a condition holds THEN run actions. Declared as DATA (a trigger event pattern + a safe condition tree + a typed action list), never as code — see OpenLoam::BusinessRules for the engine that evaluates it. Audited like any business record.
Constant Summary
Constants included from Auditable
Instance Method Summary collapse
- #action_list ⇒ Object
-
#condition_tree ⇒ Object
The stored json, defensively — a hand-created row could hold a non-hash / non-array.
- #matches_trigger?(event_name) ⇒ Boolean
Instance Method Details
#action_list ⇒ Object
34 35 36 |
# File 'app/models/open_loam/business_rule.rb', line 34 def action_list actions.is_a?(Array) ? actions : [] end |
#condition_tree ⇒ Object
The stored json, defensively — a hand-created row could hold a non-hash / non-array.
30 31 32 |
# File 'app/models/open_loam/business_rule.rb', line 30 def condition_tree condition.is_a?(Hash) ? condition : {} end |
#matches_trigger?(event_name) ⇒ Boolean
24 25 26 |
# File 'app/models/open_loam/business_rule.rb', line 24 def matches_trigger?(event_name) OpenLoam::Events.pattern_matches?(trigger, event_name) end |