Class: RoleAuthorization::Rules::Rule
- Inherits:
-
Object
- Object
- RoleAuthorization::Rules::Rule
- Defined in:
- lib/role_authorization/rules/rule.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
for calls to authorized?.
-
#controller ⇒ Object
for calls to authorized?.
-
#controller_instance ⇒ Object
for calls to authorized?.
-
#id ⇒ Object
for calls to authorized?.
-
#options ⇒ Object
Returns the value of attribute options.
-
#returning ⇒ Object
Returns the value of attribute returning.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
- #authorized?(*args) ⇒ Boolean
-
#initialize(role, options, &block) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(role, options, &block) ⇒ Rule
Returns a new instance of Rule.
10 11 12 13 14 15 16 |
# File 'lib/role_authorization/rules/rule.rb', line 10 def initialize(role, , &block) @returning = block @role = role @options = self end |
Instance Attribute Details
#action ⇒ Object
for calls to authorized?
8 9 10 |
# File 'lib/role_authorization/rules/rule.rb', line 8 def action @action end |
#controller ⇒ Object
for calls to authorized?
8 9 10 |
# File 'lib/role_authorization/rules/rule.rb', line 8 def controller @controller end |
#controller_instance ⇒ Object
for calls to authorized?
8 9 10 |
# File 'lib/role_authorization/rules/rule.rb', line 8 def controller_instance @controller_instance end |
#id ⇒ Object
for calls to authorized?
8 9 10 |
# File 'lib/role_authorization/rules/rule.rb', line 8 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/role_authorization/rules/rule.rb', line 4 def @options end |
#returning ⇒ Object
Returns the value of attribute returning.
5 6 7 |
# File 'lib/role_authorization/rules/rule.rb', line 5 def returning @returning end |
#role ⇒ Object
Returns the value of attribute role.
4 5 6 |
# File 'lib/role_authorization/rules/rule.rb', line 4 def role @role end |
Instance Method Details
#authorized?(*args) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/role_authorization/rules/rule.rb', line 18 def (*args) @controller_instance, @controller, @action, @id = args if instance_eval(&returning) true else # need to run an on_fail proc? controller_instance.instance_eval(&[:on_fail]) if [:on_fail] false end end |