Class: Exits::Rules::User
- Inherits:
-
Object
- Object
- Exits::Rules::User
- Defined in:
- lib/exits/rules/user.rb
Instance Method Summary collapse
- #allow(*actions) ⇒ Object
- #authorized?(action) ⇒ Boolean
-
#initialize ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize ⇒ User
Returns a new instance of User.
5 6 7 |
# File 'lib/exits/rules/user.rb', line 5 def initialize @actions = [] end |
Instance Method Details
#allow(*actions) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/exits/rules/user.rb', line 9 def allow(*actions) @actions = @actions | actions.flatten if @actions.size > 1 && @actions.include?(:all) raise Exits::Rules::ConfusingRulesError, "You have :all and specific actions within the same controller/user rule." end end |
#authorized?(action) ⇒ Boolean
17 18 19 20 |
# File 'lib/exits/rules/user.rb', line 17 def (action) return true if @actions.include?(:all) return @actions.include?(action) end |