@Override public Map<String, DynamicMethod> getMethods() { return origin.getMethods(); }
@JRubyMethod(name = "mix", visibility = PRIVATE) public IRubyObject mix(ThreadContext context, IRubyObject mod) { Ruby runtime = context.runtime; if (!mod.isModule()) { throw runtime.newTypeError(mod, runtime.getModule()); } for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) { if (methodLocation.getMethods().containsKey(entry.getKey())) { throw runtime.newArgumentError("method would conflict - " + entry.getKey()); } } for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) { methodLocation.getMethodsForWrite().put(entry.getKey(), entry.getValue().dup()); } return mod; }
@Override public Map<String, DynamicMethod> getMethods() { return delegate.getMethods(); }
@JRubyMethod(name = "mix", visibility = PRIVATE) public IRubyObject mix(ThreadContext context, IRubyObject mod) { Ruby runtime = context.runtime; if (!mod.isModule()) { throw runtime.newTypeError(mod, runtime.getModule()); } for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) { if (methodLocation.getMethods().containsKey(entry.getKey())) { throw runtime.newArgumentError("method would conflict - " + entry.getKey()); } } for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) { methodLocation.getMethodsForWrite().put(entry.getKey(), entry.getValue().dup()); } return mod; }
@Override public Map<String, DynamicMethod> getMethods() { return origin.getMethods(); }
@Override public Map<String, DynamicMethod> getMethods() { return delegate.getMethods(); }
/** * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. * * @param name The name of the method to search for * @return The method, or UndefinedMethod if not found */ public DynamicMethod retrieveMethod(String name) { return getMethods().get(name); }
/** * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. * * @param name The name of the method to search for * @return The method, or UndefinedMethod if not found */ public DynamicMethod retrieveMethod(String name) { return getMethods().get(name); }
/** * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. * * @param name The name of the method to search for * @return The method, or UndefinedMethod if not found */ public DynamicMethod retrieveMethod(String name) { return getMethods().get(name); }
/** * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. * * @param name The name of the method to search for * @return The method, or UndefinedMethod if not found */ public DynamicMethod retrieveMethod(String name) { return getMethods().get(name); }
protected DynamicMethod searchMethodCommon(String id) { return getMethods().get(id); }
protected DynamicMethod searchMethodCommon(String id) { return getMethods().get(id); }
public DynamicMethod searchMethodInner(String name) { DynamicMethod method = getMethods().get(name); if (method != null) return method; return superClass == null ? null : superClass.searchMethodInner(name); }
public DynamicMethod searchMethodInner(String name) { DynamicMethod method = getMethods().get(name); if (method != null) return method; return superClass == null ? null : superClass.searchMethodInner(name); }
@Override public List<MethodRef> getDeclaredMethods(RubyModule clazz) { List<MethodRef> r = new ArrayList<MethodRef>(); for (DynamicMethod m : clazz.getMethods().values()) { // TODO: not sure if this is entirely correct if (m.getImplementationClass()==clazz) r.add(new RubyMethodRef(clazz,m)); } return r; }
@Override protected DynamicMethod searchMethodCommon(String id) { // IncludedModuleWrapper needs to search prepended modules too, so search until we find methodLocation RubyModule module = origin; RubyModule methodLoc = origin.getMethodLocation(); for (; module != methodLoc; module = module.getSuperClass()) { DynamicMethod method = module.getMethods().get(id); if (method != null) return method.isNull() ? null : method; } // one last search for method location DynamicMethod method = module.getMethods().get(id); if (method != null) return method.isNull() ? null : method; return null; }
@Override protected DynamicMethod searchMethodCommon(String id) { // IncludedModuleWrapper needs to search prepended modules too, so search until we find methodLocation RubyModule module = origin; RubyModule methodLoc = origin.getMethodLocation(); for (; module != methodLoc; module = module.getSuperClass()) { DynamicMethod method = module.getMethods().get(id); if (method != null) return method.isNull() ? null : method; } // one last search for method location DynamicMethod method = module.getMethods().get(id); if (method != null) return method.isNull() ? null : method; return null; }
protected void addMethodSymbols(Ruby runtime, Set<String> seen, RubyArray ary, boolean not, Visibility visibility) { for (Map.Entry<String, DynamicMethod> entry : getMethods().entrySet()) { String id = entry.getKey(); if (seen.add(id)) { // false - not added (already seen) DynamicMethod method = entry.getValue(); if ((!not && method.getVisibility() == visibility || (not && method.getVisibility() != visibility)) && !method.isUndefined()) { ary.append(runtime.newSymbol(id)); } } } }
protected void addMethodSymbols(Ruby runtime, Set<String> seen, RubyArray ary, boolean not, Visibility visibility) { for (Map.Entry<String, DynamicMethod> entry : getMethods().entrySet()) { String id = entry.getKey(); if (seen.add(id)) { // false - not added (already seen) DynamicMethod method = entry.getValue(); if ((!not && method.getVisibility() == visibility || (not && method.getVisibility() != visibility)) && !method.isUndefined()) { ary.append(runtime.newSymbol(id)); } } } }
protected IRubyObject cloneMethods(RubyModule clone) { RubyModule realType = this.getNonIncludedClass(); for (Map.Entry<String, DynamicMethod> entry : getMethods().entrySet()) { DynamicMethod method = entry.getValue(); // Do not clone cached methods // FIXME: MRI copies all methods here if (method.getImplementationClass() == realType || method.isUndefined()) { // A cloned method now belongs to a new class. Set it. // TODO: Make DynamicMethod immutable DynamicMethod clonedMethod = method.dup(); clonedMethod.setImplementationClass(clone); clone.putMethod(entry.getKey(), clonedMethod); } } return clone; }