Permalink
Browse files

under ruby 1.9.2, Class.new.name returns nil

Adjust Authorization::Usage::Disables.usages_by_controller to behave the
same as under 1.8.7 when provided an anonymous class rather than
attempting to call .demodularize on nil.
  • Loading branch information...
1 parent 0d0015b commit c383b75f68a4a3982228afff738600544ff3b38c @jhawthorn jhawthorn committed Aug 5, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/declarative_authorization/maintenance.rb
@@ -60,9 +60,10 @@ def self.usages_by_controller
end
rescue Errno::ENOENT
end
- controllers = []
- ObjectSpace.each_object(Class) do |obj|
- controllers << obj if obj.ancestors.include?(ActionController::Base) and obj != ActionController::Base and obj.name.demodulize != 'ApplicationController'
+ controllers = ObjectSpace.each_object(Class).select do |obj|
+ obj.ancestors.include?(ActionController::Base) &&
+ obj != ActionController::Base &&
+ (!obj.name || obj.name.demodulize != 'ApplicationController')
end
controllers.inject({}) do |memo, controller|

0 comments on commit c383b75

Please sign in to comment.