authorize_resource(*args)
click to toggle source
def authorize_resource(*args)
cancan_resource_class.add_before_filter(self, :authorize_resource, *args)
end
cancan_resource_class()
click to toggle source
def cancan_resource_class
if ancestors.map(&:to_s).include? "InheritedResources::Actions"
InheritedResource
else
ControllerResource
end
end
cancan_skipper()
click to toggle source
def cancan_skipper
@_cancan_skipper ||= {:authorize => {}, :load => {}}
end
check_authorization(options = {})
click to toggle source
def check_authorization(options = {})
self.after_filter(options.slice(:only, :except)) do |controller|
next if controller.instance_variable_defined?(:@_authorized)
next if options[:if] && !controller.send(options[:if])
next if options[:unless] && controller.send(options[:unless])
raise AuthorizationNotPerformed, "This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check."
end
end
load_and_authorize_resource(*args)
click to toggle source
def load_and_authorize_resource(*args)
cancan_resource_class.add_before_filter(self, :load_and_authorize_resource, *args)
end
load_resource(*args)
click to toggle source
def load_resource(*args)
cancan_resource_class.add_before_filter(self, :load_resource, *args)
end
skip_authorization(*args)
click to toggle source
def skip_authorization(*args)
raise ImplementationRemoved, "The CanCan skip_authorization method has been renamed to skip_authorization_check. Please update your code."
end
skip_authorization_check(*args)
click to toggle source
def skip_authorization_check(*args)
self.before_filter(*args) do |controller|
controller.instance_variable_set(:@_authorized, true)
end
end
skip_authorize_resource(*args)
click to toggle source
def skip_authorize_resource(*args)
options = args.extract_options!
name = args.first
cancan_skipper[:authorize][name] = options
end
skip_load_and_authorize_resource(*args)
click to toggle source
def skip_load_and_authorize_resource(*args)
skip_load_resource(*args)
skip_authorize_resource(*args)
end
skip_load_resource(*args)
click to toggle source
def skip_load_resource(*args)
options = args.extract_options!
name = args.first
cancan_skipper[:load][name] = options
end