org.jruby.RubyModule.getMethods()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.jruby.RubyModule.getMethods方法的一些代码示例,展示了RubyModule.getMethods的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyModule.getMethods方法的具体详情如下:
包路径:org.jruby.RubyModule
类名称:RubyModule
方法名:getMethods

RubyModule.getMethods介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-core

@Override
public Map<String, DynamicMethod> getMethods() {
  return origin.getMethods();
}

代码示例来源:origin: org.jruby/jruby-complete

@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;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
public Map<String, DynamicMethod> getMethods() {
  return delegate.getMethods();
}

代码示例来源:origin: org.jruby/jruby-core

@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;
}

代码示例来源:origin: org.jruby/jruby-complete

@Override
public Map<String, DynamicMethod> getMethods() {
  return origin.getMethods();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
public Map<String, DynamicMethod> getMethods() {
  return delegate.getMethods();
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * 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);
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * 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);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * 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);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * 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);
}

代码示例来源:origin: org.jruby/jruby-core

protected DynamicMethod searchMethodCommon(String id) {
  return getMethods().get(id);
}

代码示例来源:origin: org.jruby/jruby-complete

protected DynamicMethod searchMethodCommon(String id) {
  return getMethods().get(id);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public DynamicMethod searchMethodInner(String name) {
  DynamicMethod method = getMethods().get(name);
  
  if (method != null) return method;
  
  return superClass == null ? null : superClass.searchMethodInner(name);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public DynamicMethod searchMethodInner(String name) {
  DynamicMethod method = getMethods().get(name);
  
  if (method != null) return method;
  
  return superClass == null ? null : superClass.searchMethodInner(name);
}

代码示例来源:origin: stapler/stapler

@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;
}

代码示例来源:origin: org.jruby/jruby-complete

@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;
}

代码示例来源:origin: org.jruby/jruby-core

@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;
}

代码示例来源:origin: org.jruby/jruby-complete

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));
      }
    }
  }
}

代码示例来源:origin: org.jruby/jruby-core

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));
      }
    }
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

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;
}

相关文章

微信公众号

最新文章

更多

RubyModule类方法