Class: Rule
- Inherits:
-
Object
- Object
- Rule
- Defined in:
- lib/turnstile/rule.rb
Overview
Rule class A simple to class to manipulate the array of rules
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#active ⇒ Object
Returns the value of attribute active.
-
#allow ⇒ Object
Returns the value of attribute allow.
-
#controller ⇒ Object
Returns the value of attribute controller.
Instance Method Summary collapse
-
#allow_or_deny? ⇒ Boolean
The current rule allows or denies some action?.
- #allows? ⇒ Boolean
- #denies? ⇒ Boolean
-
#initialize(rules) ⇒ Rule
constructor
A new instance of Rule.
- #is_active? ⇒ Boolean
Constructor Details
#initialize(rules) ⇒ Rule
Returns a new instance of Rule.
7 8 9 10 11 12 13 |
# File 'lib/turnstile/rule.rb', line 7 def initialize(rules) @action = rules[:action] @controller = rules[:controller] @allow = rules[:allow] @active = rules[:active] end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/turnstile/rule.rb', line 5 def action @action end |
#active ⇒ Object
Returns the value of attribute active.
5 6 7 |
# File 'lib/turnstile/rule.rb', line 5 def active @active end |
#allow ⇒ Object
Returns the value of attribute allow.
5 6 7 |
# File 'lib/turnstile/rule.rb', line 5 def allow @allow end |
#controller ⇒ Object
Returns the value of attribute controller.
5 6 7 |
# File 'lib/turnstile/rule.rb', line 5 def controller @controller end |
Instance Method Details
#allow_or_deny? ⇒ Boolean
The current rule allows or denies some action?
16 17 18 |
# File 'lib/turnstile/rule.rb', line 16 def allow_or_deny? @allow == true ? :allow : :deny end |
#allows? ⇒ Boolean
24 25 26 |
# File 'lib/turnstile/rule.rb', line 24 def allows? @allow ? true : false end |
#denies? ⇒ Boolean
28 29 30 |
# File 'lib/turnstile/rule.rb', line 28 def denies? @allow ? false : true end |
#is_active? ⇒ Boolean
20 21 22 |
# File 'lib/turnstile/rule.rb', line 20 def is_active? @active end |