Class: Denied::Restriction
- Inherits:
-
Object
- Object
- Denied::Restriction
- Defined in:
- lib/denied/restriction.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#allow_if ⇒ Object
Returns the value of attribute allow_if.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Restriction
constructor
A new instance of Restriction.
- #restricts?(action_name) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ Restriction
Returns a new instance of Restriction.
5 6 7 8 9 10 11 |
# File 'lib/denied/restriction.rb', line 5 def initialize(*args) = args. @role = [:role] @allow_if = [:allow_if] @actions = args actions.empty? and raise ArgumentError, "expected actions to restrict, but got #{actions.inspect}" end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
3 4 5 |
# File 'lib/denied/restriction.rb', line 3 def actions @actions end |
#allow_if ⇒ Object
Returns the value of attribute allow_if.
3 4 5 |
# File 'lib/denied/restriction.rb', line 3 def allow_if @allow_if end |
#role ⇒ Object
Returns the value of attribute role.
3 4 5 |
# File 'lib/denied/restriction.rb', line 3 def role @role end |
Instance Method Details
#restricts?(action_name) ⇒ Boolean
13 14 15 |
# File 'lib/denied/restriction.rb', line 13 def restricts?(action_name) actions.include?(action_name.to_sym) end |