under ruby 1.9.2, .name returns nil for anonymous classes #151

Merged
merged 1 commit into from Sep 23, 2012

Conversation

Projects
None yet
2 participants
Contributor

jhawthorn commented Aug 5, 2012

Inside Authorization::Usage::Disables.usages_by_controller is the line

controllers << obj if obj.ancestors.include?(ActionController::Base) and obj != ActionController::Base and obj.name.demodulize != 'ApplicationController'

Under 1.9.2 and above this raises an exception when there it encounters an anonymous class, where .name returns nil (1.8.7 returns '').

This fix makes all rails 3 tests pass on 1.9.2 and 1.9.3. http://travis-ci.org/#!/jhawthorn/declarative_authorization/builds/2041629

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.

stffn added a commit that referenced this pull request Sep 23, 2012

Merge pull request #151 from jhawthorn/class_nil_in_19
under ruby 1.9.2, .name returns nil for anonymous classes

@stffn stffn merged commit e9e1aff into stffn:master Sep 23, 2012

Owner

stffn commented Sep 23, 2012

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment