Sha256: c3b7133e06e9aa66a433d380e3c87fb3bdb13c966db8b81c86c082227be78e04
Contents?: true
Size: 903 Bytes
Versions: 21
Compression:
Stored size: 903 Bytes
Contents
require 'effective_resources/engine' require 'effective_resources/version' module EffectiveResources # The following are all valid config keys mattr_accessor :authorization_method def self.setup yield self end def self.authorized?(controller, action, resource) @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact return !!authorization_method unless authorization_method.respond_to?(:call) controller = controller.controller if controller.respond_to?(:controller) begin !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method) rescue *@_exceptions false end end def self.authorize!(controller, action, resource) raise Effective::AccessDenied unless authorized?(controller, action, resource) end end
Version data entries
21 entries across 21 versions & 1 rubygems