public static RubyModule getModuleFromPath(Ruby runtime, String path) { RubyModule value = runtime.getClassFromPath(path); if (!value.isModule()) throw runtime.newArgumentError(path + " does not refer module"); return value; }
public static RubyModule getSuperClassForDefined(Ruby runtime, RubyModule klazz) { RubyModule superklazz = klazz.getSuperClass(); if (superklazz == null && klazz.isModule()) superklazz = runtime.getObject(); return superklazz; }
public static RubyModule getModuleFromPath(Ruby runtime, String path) { final RubyModule value = getConstantFromPath(runtime, path); if ( ! value.isModule() ) throw runtime.newArgumentError(path + " does not refer module"); return value; }
public static RubyModule getModuleFromPath(Ruby runtime, String path) { final RubyModule value = getConstantFromPath(runtime, path); if ( ! value.isModule() ) throw runtime.newArgumentError(path + " does not refer module"); return value; }
public static RubyModule getSuperClassForDefined(Ruby runtime, RubyModule klazz) { RubyModule superklazz = klazz.getSuperClass(); if (superklazz == null && klazz.isModule()) superklazz = runtime.getObject(); return superklazz; }
public static RubyModule getSuperClassForDefined(Ruby runtime, RubyModule klazz) { RubyModule superklazz = klazz.getSuperClass(); if (superklazz == null && klazz.isModule()) superklazz = runtime.getObject(); return superklazz; }
public static RubyModule getModuleFromPath(Ruby runtime, String path) { RubyModule value = runtime.getClassFromPath(path); if (!value.isModule()) throw runtime.newArgumentError(path + " does not refer module"); return value; }
public static RubyModule getSuperClassForDefined(Ruby runtime, RubyModule klazz) { RubyModule superklazz = klazz.getSuperClass(); if (superklazz == null && klazz.isModule()) superklazz = runtime.getObject(); return superklazz; }
private DynamicMethod deepMethodSearch(String name, Ruby runtime) { DynamicMethod method = searchMethod(name); if (method.isUndefined() && isModule()) { method = runtime.getObject().searchMethod(name); } if (method.isUndefined()) { throw runtime.newNameError("undefined method '" + name + "' for " + (isModule() ? "module" : "class") + " '" + getName() + "'", name); } return method; }
private DynamicMethod deepMethodSearch(String name, Ruby runtime) { DynamicMethod method = searchMethod(name); if (method.isUndefined() && isModule()) { method = runtime.getObject().searchMethod(name); } if (method.isUndefined()) { throw runtime.newNameError("undefined method '" + name + "' for " + (isModule() ? "module" : "class") + " '" + getName() + "'", name); } return method; }
public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule) throws RaiseException { // Module methods can always be transplanted if (!originModule.isModule() && !hasModuleInHierarchy(originModule)) { if (originModule instanceof MetaClass) { throw context.runtime.newTypeError("can't bind singleton method to a different class"); } else { throw context.runtime.newTypeError("bind argument must be an instance of " + originModule.getName()); } } }
public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule) throws RaiseException { // Module methods can always be transplanted if (!originModule.isModule() && !hasModuleInHierarchy(originModule)) { if (originModule instanceof MetaClass) { throw context.runtime.newTypeError("can't bind singleton method to a different class"); } else { throw context.runtime.newTypeError("bind argument must be an instance of " + originModule.getName()); } } }
private static void usingModuleRecursive(RubyModule cref, RubyModule refinedModule) { Ruby runtime = cref.getRuntime(); RubyClass superClass = refinedModule.getSuperClass(); // For each superClass of the refined module also use their refinements for the given cref if (superClass != null) usingModuleRecursive(cref, superClass); RubyModule realRefinedModule; if (refinedModule instanceof IncludedModule) { realRefinedModule = ((IncludedModule) refinedModule).getDelegate(); } else if (refinedModule.isModule()) { realRefinedModule = refinedModule; } else { throw runtime.newTypeError("wrong argument type " + refinedModule.getName() + " (expected Module)"); } Map<RubyModule, RubyModule> refinements = realRefinedModule.refinements; if (refinements == null) return; // No refinements registered for this module for (Map.Entry<RubyModule, RubyModule> entry: refinements.entrySet()) { usingRefinement(runtime, cref, entry.getKey(), entry.getValue()); } }
private DynamicMethod deepMethodSearch(String id, Ruby runtime) { DynamicMethod method = searchMethod(id); if (method.isUndefined() && isModule()) method = runtime.getObject().searchMethod(id); if (method.isUndefined()) { RubySymbol name = runtime.newSymbol(id); throw runtime.newNameError(undefinedMethodMessage(runtime, name, rubyName(), isModule()), id); } return method; }
private DynamicMethod deepMethodSearch(String id, Ruby runtime) { DynamicMethod method = searchMethod(id); if (method.isUndefined() && isModule()) method = runtime.getObject().searchMethod(id); if (method.isUndefined()) { RubySymbol name = runtime.newSymbol(id); throw runtime.newNameError(undefinedMethodMessage(runtime, name, rubyName(), isModule()), id); } return method; }
public static String getPathFromClass(RubyModule clazz) { String path = clazz.getName(); if (path.charAt(0) == '#') { String classOrModule = clazz.isClass() ? "class" : "module"; throw clazz.getRuntime().newTypeError("can't dump anonymous " + classOrModule + " " + path); } RubyModule real = clazz.isModule() ? clazz : ((RubyClass)clazz).getRealClass(); if (clazz.getRuntime().getClassFromPath(path) != real) { throw clazz.getRuntime().newTypeError(path + " can't be referred"); } return path; }
public static String getPathFromClass(RubyModule clazz) { String path = clazz.getName(); if (path.charAt(0) == '#') { String classOrModule = clazz.isClass() ? "class" : "module"; throw clazz.getRuntime().newTypeError("can't dump anonymous " + classOrModule + " " + path); } RubyModule real = clazz.isModule() ? clazz : ((RubyClass)clazz).getRealClass(); if (clazz.getRuntime().getClassFromPath(path) != real) { throw clazz.getRuntime().newTypeError(path + " can't be referred"); } return path; }
/** rb_mod_extend_object * */ @JRubyMethod(name = "extend_object", required = 1, visibility = PRIVATE) public IRubyObject extend_object(IRubyObject obj) { if (!isModule()) { throw getRuntime().newTypeError(this, getRuntime().getModule()); } obj.getSingletonClass().includeModule(this); return obj; }
/** rb_mod_extend_object * */ @JRubyMethod(name = "extend_object", required = 1, visibility = PRIVATE) public IRubyObject extend_object(IRubyObject obj) { if (!isModule()) { throw getRuntime().newTypeError(this, getRuntime().getModule()); } obj.getSingletonClass().includeModule(this); return obj; }
/** rb_mod_prepend_features * */ @JRubyMethod(name = "prepend_features", required = 1, visibility = PRIVATE) public RubyModule prepend_features(IRubyObject include) { if (!isModule()) { throw getRuntime().newTypeError(this, getRuntime().getModule()); } if (!(include instanceof RubyModule)) { throw getRuntime().newTypeError(include, getRuntime().getModule()); } if (!(include.isModule() || include.isClass())) { throw getRuntime().newTypeError(include, getRuntime().getModule()); } ((RubyModule) include).prependModule(this); return this; }