module FlexibleAccessibility::Filters
Private Instance Methods
allow_route()
click to toggle source
# File lib/flexible_accessibility/filters.rb, line 45 def allow_route self.class.instance_variable_set(:@_route_permitted, true) end
check_if_route_is_permitted()
click to toggle source
Check the @_route_permitted variable state
# File lib/flexible_accessibility/filters.rb, line 54 def check_if_route_is_permitted raise AccessDeniedException.new(current_route, nil) unless self.class.instance_variable_get(:@_route_permitted) end
check_permission_to_route()
click to toggle source
Check access to route and we expected the existing of current_user helper
# File lib/flexible_accessibility/filters.rb, line 33 def check_permission_to_route route_provider = RouteProvider.new(self.class) if route_provider.verifiable_routes_list.include?(current_action) raise UserNotLoggedInException.new(current_route, nil) if logged_user.nil? AccessProvider.is_action_permitted_for_user?(current_route, logged_user) ? allow_route : deny_route elsif route_provider.non_verifiable_routes_list.include?(current_action) allow_route else deny_route end end
current_action()
click to toggle source
# File lib/flexible_accessibility/filters.rb, line 17 def current_action # ActionController::Routing::Routes.recognize_path request.env["PATH_INFO"][:action] params[:action] end
current_resource()
click to toggle source
Detect current controller and action and return a permission
# File lib/flexible_accessibility/filters.rb, line 12 def current_resource # ActionController::Routing::Routes.recognize_path request.env["PATH_INFO"][:controller] params[:controller] end
current_route()
click to toggle source
# File lib/flexible_accessibility/filters.rb, line 22 def current_route "#{current_resource}##{current_action}" end
deny_route()
click to toggle source
# File lib/flexible_accessibility/filters.rb, line 49 def deny_route self.class.instance_variable_set(:@_route_permitted, false) end
logged_user()
click to toggle source
Expected the existing of current_user helper
# File lib/flexible_accessibility/filters.rb, line 27 def logged_user return current_user if defined?(current_user) raise NoWayToDetectLoggerUserException unless defined?(current_user) end