62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/controllers/concerns/glib/auth/policy.rb', line 62
def authorize_resource(*args)
options = args.
resource_name = args.first
self.before_action(options.slice(:only, :except, :if, :unless)) do |controller|
resource_name ||= resource_name_from_controller
if !(resource_key = options[:class]).nil?
resource = case resource_key
when false
resource_name.to_sym
when Symbol, Class
resource_key
else
raise "Invalid resource class: #{resource_key}"
end
authorize resource
elsif (resource_instance = controller.instance_variable_get("@#{resource_name}"))
authorize resource_instance
else
authorize resource_name.camelize.constantize
end
verify_authorized
end
end
|