Skip to content

Instantly share code, notes, and snippets.

@wycats
Created January 23, 2009 06:18
Show Gist options
  • Save wycats/50912 to your computer and use it in GitHub Desktop.
Save wycats/50912 to your computer and use it in GitHub Desktop.
package org.jruby.runtime.callsite;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.RubyModule;
import org.jruby.RubyClass;
import org.jruby.RubyObject;
public class RespondToCallSite extends NormalCachingCallSite {
public RespondToCallSite() {
super("respond_to?");
}
@Override
public IRubyObject call(ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg) {
RubyClass klass = self.getMetaClass();
if(!klass.searchMethod(arg.toString()).isUndefined()) {
return context.getRuntime().getTrue();
} else {
return context.getRuntime().getFalse();
}
}
}
Index: src/org/jruby/RubyInstanceConfig.java
===================================================================
--- src/org/jruby/RubyInstanceConfig.java (revision 8874)
+++ src/org/jruby/RubyInstanceConfig.java (working copy)
@@ -217,6 +217,8 @@
= SafePropertyAccessor.getProperty("jruby.jit.exclude");
public static boolean nativeEnabled = true;
+ public static final boolean YEHUDA_FAIL
+ = SafePropertyAccessor.getBoolean("yehuda.fail");
public static interface LoadServiceCreator {
LoadService create(Ruby runtime);
public synchronized static CallSite getCallSite(String name) {
if (RubyInstanceConfig.YEHUDA_FAIL) {
if (name.equals("respond_to?")) {
return new RespondToCallSite();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment