Class: Exits::Rules
- Inherits:
-
Object
- Object
- Exits::Rules
- Defined in:
- lib/exits/rules.rb,
lib/exits/rules/user.rb,
lib/exits/rules/controller.rb
Defined Under Namespace
Classes: ConfusingRulesError, Controller, Unauthorized, User
Instance Method Summary collapse
- #add(controller_class, klass, *actions) ⇒ Object
- #authorized?(controller_class, klass, action) ⇒ Boolean
-
#initialize ⇒ Rules
constructor
A new instance of Rules.
Constructor Details
#initialize ⇒ Rules
Returns a new instance of Rules.
8 9 10 |
# File 'lib/exits/rules.rb', line 8 def initialize @controllers = Hash.new end |
Instance Method Details
#add(controller_class, klass, *actions) ⇒ Object
12 13 14 15 |
# File 'lib/exits/rules.rb', line 12 def add(controller_class, klass, *actions) @controllers[controller_class] ||= Exits::Rules::Controller.new @controllers[controller_class][klass] = actions.flatten end |
#authorized?(controller_class, klass, action) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/exits/rules.rb', line 17 def (controller_class, klass, action) controller = @controllers.fetch(controller_class, {}) return false if controller.nil? controller. klass, action end |