Class: PolicyManager::Rule
- Inherits:
-
Object
- Object
- PolicyManager::Rule
- Defined in:
- lib/policy_manager/rule.rb
Instance Attribute Summary collapse
-
#blocking ⇒ Object
Returns the value of attribute blocking.
-
#if ⇒ Object
Returns the value of attribute if.
-
#name ⇒ Object
Returns the value of attribute name.
-
#on_accept ⇒ Object
Returns the value of attribute on_accept.
-
#on_reject ⇒ Object
Returns the value of attribute on_reject.
-
#validates_on ⇒ Object
Returns the value of attribute validates_on.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Rule
constructor
A new instance of Rule.
- #on_accept_callback ⇒ Object
- #on_reject_callback ⇒ Object
- #terms ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Rule
Returns a new instance of Rule.
10 11 12 13 14 15 16 17 18 |
# File 'lib/policy_manager/rule.rb', line 10 def initialize(opts={}) self.name = opts[:name] self.blocking = opts[:blocking] self.validates_on = opts[:validates_on] self.if = opts[:if] self.on_reject = opts[:on_reject] self.on_accept = opts[:on_accept] self end |
Instance Attribute Details
#blocking ⇒ Object
Returns the value of attribute blocking.
3 4 5 |
# File 'lib/policy_manager/rule.rb', line 3 def blocking @blocking end |
#if ⇒ Object
Returns the value of attribute if.
3 4 5 |
# File 'lib/policy_manager/rule.rb', line 3 def if @if end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/policy_manager/rule.rb', line 3 def name @name end |
#on_accept ⇒ Object
Returns the value of attribute on_accept.
3 4 5 |
# File 'lib/policy_manager/rule.rb', line 3 def on_accept @on_accept end |
#on_reject ⇒ Object
Returns the value of attribute on_reject.
3 4 5 |
# File 'lib/policy_manager/rule.rb', line 3 def on_reject @on_reject end |
#validates_on ⇒ Object
Returns the value of attribute validates_on.
3 4 5 |
# File 'lib/policy_manager/rule.rb', line 3 def validates_on @validates_on end |
Instance Method Details
#on_accept_callback ⇒ Object
32 33 34 |
# File 'lib/policy_manager/rule.rb', line 32 def on_accept_callback @on_accept.call if @on_accept.is_a?(Proc) end |
#on_reject_callback ⇒ Object
28 29 30 |
# File 'lib/policy_manager/rule.rb', line 28 def on_reject_callback @on_reject.call if @on_reject.is_a?(Proc) end |
#terms ⇒ Object
24 25 26 |
# File 'lib/policy_manager/rule.rb', line 24 def terms Term.where("rule =?", self.name) end |