Created
January 23, 2009 06:18
-
-
Save wycats/50912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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