class Denied::Gatekeeper
Public Instance Methods
eye(controller)
click to toggle source
# File lib/denied/gatekeeper.rb, line 3 def eye(controller) restriction = current_restriction(controller) restriction and handle_restriction(restriction, controller) end
Private Instance Methods
current_restriction(controller)
click to toggle source
# File lib/denied/gatekeeper.rb, line 20 def current_restriction(controller) controller.restrictions or return controller.restrictions.find do |restriction| restriction.restricts?(controller.action_name) end end
handle_restriction(restriction, controller)
click to toggle source
# File lib/denied/gatekeeper.rb, line 10 def handle_restriction(restriction, controller) controller.current_user or raise Denied::LoginRequired if restriction.allow_if unless controller.__send__(restriction.allow_if) raise Denied::AccessDenied, reason: restriction end end end