Class: Bali::Rule
- Inherits:
-
Object
- Object
- Bali::Rule
- Defined in:
- lib/bali/foundations/rule/rule.rb
Overview
for internal use, representing one, single, atomic rule
Instance Attribute Summary collapse
-
#auth_val ⇒ Object
auth_val is either :can or :cannot.
-
#decider ⇒ Object
if decider is defined, a rule is executed only if decider evaluates to true.
-
#decider_type ⇒ Object
either unless or if.
-
#operation ⇒ Object
readonly
what is the operation: create, update, delete, or any other.
Instance Method Summary collapse
- #has_decider? ⇒ Boolean
-
#initialize(auth_val, operation) ⇒ Rule
constructor
A new instance of Rule.
- #is_discouragement? ⇒ Boolean
Constructor Details
#initialize(auth_val, operation) ⇒ Rule
Returns a new instance of Rule.
14 15 16 17 18 |
# File 'lib/bali/foundations/rule/rule.rb', line 14 def initialize(auth_val, operation) self.auth_val = auth_val @operation = operation self end |
Instance Attribute Details
#auth_val ⇒ Object
auth_val is either :can or :cannot
4 5 6 |
# File 'lib/bali/foundations/rule/rule.rb', line 4 def auth_val @auth_val end |
#decider ⇒ Object
if decider is defined, a rule is executed only if decider evaluates to true
10 11 12 |
# File 'lib/bali/foundations/rule/rule.rb', line 10 def decider @decider end |
#decider_type ⇒ Object
either unless or if
12 13 14 |
# File 'lib/bali/foundations/rule/rule.rb', line 12 def decider_type @decider_type end |
#operation ⇒ Object (readonly)
what is the operation: create, update, delete, or any other
7 8 9 |
# File 'lib/bali/foundations/rule/rule.rb', line 7 def operation @operation end |
Instance Method Details
#has_decider? ⇒ Boolean
44 45 46 47 |
# File 'lib/bali/foundations/rule/rule.rb', line 44 def has_decider? raise Bali::DslError, "has decider but not sure if it is if or unless type decider" if self.decider.is_a?(Proc) && self.decider_type.nil? self.decider.is_a?(Proc) end |
#is_discouragement? ⇒ Boolean
39 40 41 42 |
# File 'lib/bali/foundations/rule/rule.rb', line 39 def is_discouragement? # TODO: in version 3.0 remove :cant self.auth_val == :cannot || self.auth_val == :cant end |