Skip to content

Commit

Permalink
Add namespace support for authorization_usage
Browse files Browse the repository at this point in the history
  • Loading branch information
bterkuile authored and stffn committed Apr 21, 2011
1 parent e891e44 commit 2737369
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/views/authorization_usages/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<% @auth_usages_by_controller.keys.sort {|c1, c2| c1.name <=> c2.name}.each do |controller| %>
<% default_context = controller.controller_name.to_sym rescue nil %>
<tr>
<th colspan="3"><%= h controller.controller_name %></th>
<th colspan="3"><%= h controller.name.underscore.sub(/_controller\Z/, '') %></th>
</tr>
<% @auth_usages_by_controller[controller].keys.sort {|c1, c2| c1.to_s <=> c2.to_s}.each do |action| %>
<% auth_info = @auth_usages_by_controller[controller][action] %>
Expand Down
9 changes: 3 additions & 6 deletions lib/declarative_authorization/maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,14 @@ module Usage
def self.usages_by_controller
# load each application controller
begin
Dir.foreach(File.join(::Rails.root, %w{app controllers})) do |entry|
if entry =~ /^\w+_controller\.rb$/
require File.join(::Rails.root, %w{app controllers}, entry)
end
Dir.glob(File.join(::Rails.root, 'app', 'controllers', '**', '*_controller\.rb')) do |entry|
require entry
end
rescue Errno::ENOENT
end
controllers = []
ObjectSpace.each_object(Class) do |obj|
controllers << obj if obj.ancestors.include?(ActionController::Base) and
!%w{ActionController::Base ApplicationController}.include?(obj.name)
controllers << obj if obj.ancestors.include?(ActionController::Base) and obj != ActionController::Base and obj.name.demodulize != 'ApplicationController'
end

controllers.inject({}) do |memo, controller|
Expand Down

0 comments on commit 2737369

Please sign in to comment.