Skip to content

Commit

Permalink
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -225,35 +225,34 @@ public static Map<String, Object> getAllClassVariables(RubyModule module) {
public static Object lookupClassVariable(RubyModule module, String name) {
CompilerAsserts.neverPartOfCompilation();

// Look in the current module
Object value = module.getClassVariables().get(name);
if (value != null) {
return value;
}

// If singleton class, check attached module.
if (module instanceof RubyClass) {
RubyClass klass = (RubyClass) module;

if (klass.isSingleton() && klass.getAttached() != null) {
if (klass.isSingleton() && klass.getAttached() instanceof RubyModule) {
module = klass.getAttached();
}
}

Object value;

// Look in the current module
value = module.getClassVariables().get(name);

if (value != null) {
return value;
value = module.getClassVariables().get(name);
if (value != null) {
return value;
}
}
}

// Look in ancestors
for (RubyModule ancestor : module.parentAncestors()) {
value = ancestor.getClassVariables().get(name);

if (value != null) {
return value;
}
}

// Nothing found

return null;
}

0 comments on commit 0f7a77d

Please sign in to comment.