Skip to content

Commit

Permalink
under ruby 1.9.2, Class.new.name returns nil
Browse files Browse the repository at this point in the history
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
jhawthorn committed Aug 5, 2012
1 parent 0d0015b commit c383b75
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/declarative_authorization/maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit c383b75

Please sign in to comment.