Sha256: d24ee71c6263e277eababd16ba44ef2e2ec6ea95425dde43f8bbf6a4020b3294
Contents?: true
Size: 941 Bytes
Versions: 65
Compression:
Stored size: 941 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.new('Access Denied', action, resource) unless authorized?(controller, action, resource) end end
Version data entries
65 entries across 65 versions & 1 rubygems