lib/adeia/controller_resource.rb in adeia-0.15.0 vs lib/adeia/controller_resource.rb in adeia-0.15.1
- old
+ new
@@ -5,26 +5,26 @@
class ControllerResource
def self.add_before_filter(controller_class, method, **args)
controller_class.send(:before_action, args.slice(:only, :except, :if, :unless)) do |controller|
- ControllerResource.send(method, controller)
+ ControllerResource.send(method, controller, **args)
end
end
- def self.load_resource_or_records_and_authorize(controller)
+ def self.load_resource_or_records_and_authorize(controller, **args)
case controller.action_name
when "index"
- controller.authorize_and_load_records!
+ controller.authorize_and_load_records!(**args)
when "show", "edit", "update", "destroy"
- controller.load_and_authorize!
+ controller.load_and_authorize!(**args)
else
- controller.authorize!
+ controller.authorize!(**args)
end
end
- def self.require_login(controller)
+ def self.require_login(controller, **args)
controller.require_login!
end
def self.get_controller_and_resource(element, resource)
if element.is_a? String
@@ -96,10 +96,14 @@
@resource.class
else
begin
@controller_name.classify.constantize
rescue NameError
- @controller_name.classify.demodulize.constantize
+ begin
+ @controller_name.classify.demodulize.constantize
+ rescue NameError
+ nil
+ end
end
end
end
def resource_name