org.jruby.RubyClass.respondsToMethod()方法的使用及代码示例

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

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

RubyClass.respondsToMethod介绍

暂无

代码示例

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

private IRubyObject respond_to(final ThreadContext context, IRubyObject mname, final boolean includePrivate) {
  RubySymbol name = TypeConverter.checkID(mname);
  if (getMetaClass().respondsToMethod(name.idString(), !includePrivate)) return context.tru;
  /*
  if ( ( name = BlankSlateWrapper.handlesMethod(name) ) != null ) {
    RubyBoolean bound = checkMetaClassBoundMethod(context, name, includePrivate);
    if ( bound != null ) return bound;
    return context.fals; // un-bound (removed) method
  }
  */
  //if ( ! (mname instanceof RubySymbol) ) mname = context.runtime.newSymbol(name);
  //IRubyObject respond = Helpers.invoke(context, this, "respond_to_missing?", mname, context.runtime.newBoolean(includePrivate));
  //return context.runtime.newBoolean(respond.isTrue());
  return context.nil; // NOTE: this is wrong - should be true but compatibility first, for now
}

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

private IRubyObject respond_to(final ThreadContext context, IRubyObject mname, final boolean includePrivate) {
  RubySymbol name = TypeConverter.checkID(mname);
  if (getMetaClass().respondsToMethod(name.idString(), !includePrivate)) return context.tru;
  /*
  if ( ( name = BlankSlateWrapper.handlesMethod(name) ) != null ) {
    RubyBoolean bound = checkMetaClassBoundMethod(context, name, includePrivate);
    if ( bound != null ) return bound;
    return context.fals; // un-bound (removed) method
  }
  */
  //if ( ! (mname instanceof RubySymbol) ) mname = context.runtime.newSymbol(name);
  //IRubyObject respond = Helpers.invoke(context, this, "respond_to_missing?", mname, context.runtime.newBoolean(includePrivate));
  //return context.runtime.newBoolean(respond.isTrue());
  return context.nil; // NOTE: this is wrong - should be true but compatibility first, for now
}

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

/** obj_respond_to
 *
 * respond_to?( aSymbol, includePriv=false ) -> true or false
 *
 * Returns true if this object responds to the given method. Private
 * methods are included in the search only if the optional second
 * parameter evaluates to true.
 *
 * @return true if this responds to the given method
 *
 * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1
 *
 * Going back to splitting according to method arity. MRI is wrong
 * about most of these anyway, and since we have arity splitting
 * in both the compiler and the interpreter, the performance
 * benefit is important for this method.
 */
@Deprecated // NOTE: does not match Ruby 2.x rules (does method bound check only)
public final RubyBoolean respond_to_p(IRubyObject mname) {
  return getRuntime().newBoolean(getMetaClass().respondsToMethod(mname.asJavaString(), true));
}

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

/** obj_respond_to
 *
 * respond_to?( aSymbol, includePriv=false ) -> true or false
 *
 * Returns true if this object responds to the given method. Private
 * methods are included in the search only if the optional second
 * parameter evaluates to true.
 *
 * @return true if this responds to the given method
 *
 * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1
 *
 * Going back to splitting according to method arity. MRI is wrong
 * about most of these anyway, and since we have arity splitting
 * in both the compiler and the interpreter, the performance
 * benefit is important for this method.
 */
@Deprecated // NOTE: does not match Ruby 2.x rules (does method bound check only)
public final RubyBoolean respond_to_p(IRubyObject mname) {
  return getRuntime().newBoolean(getMetaClass().respondsToMethod(mname.asJavaString(), true));
}

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

final RubyBoolean respond_to_p(ThreadContext context, IRubyObject methodName, final boolean includePrivate) {
  final Ruby runtime = context.runtime;
  final String name = methodName.asJavaString();
  if (getMetaClass().respondsToMethod(name, !includePrivate)) return runtime.getTrue();
  // MRI (1.9) always passes down a symbol when calling respond_to_missing?
  if ( ! (methodName instanceof RubySymbol) ) methodName = runtime.newSymbol(name);
  IRubyObject respond = sites(context).respond_to_missing.call(context, this, this, methodName, runtime.newBoolean(includePrivate));
  return runtime.newBoolean( respond.isTrue() );
}

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

final RubyBoolean respond_to_p(ThreadContext context, IRubyObject methodName, final boolean includePrivate) {
  final Ruby runtime = context.runtime;
  final String name = methodName.asJavaString();
  if (getMetaClass().respondsToMethod(name, !includePrivate)) return runtime.getTrue();
  // MRI (1.9) always passes down a symbol when calling respond_to_missing?
  if ( ! (methodName instanceof RubySymbol) ) methodName = runtime.newSymbol(name);
  IRubyObject respond = sites(context).respond_to_missing.call(context, this, this, methodName, runtime.newBoolean(includePrivate));
  return runtime.newBoolean( respond.isTrue() );
}

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

return getMetaClass().respondsToMethod(name, false);

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

return getMetaClass().respondsToMethod(name, false);

相关文章

微信公众号

最新文章

更多

RubyClass类方法