Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jruby.demo.ext;
 
 import org.jruby.Ruby;
This is a demonstration of how to bind method_missing in a JRuby extension
public class MethodMissing extends RubyObject {
    public static void init(Ruby ruby) {
        RubyClass mm = ruby.defineClass("MethodMissing"ruby.getObject(), new ObjectAllocator() {
            public IRubyObject allocate(Ruby runtimeRubyClass klazz) {
                return new MethodMissing(runtimeklazz);
            }
        });
        mm.defineAnnotatedMethods(MethodMissing.class);
    }
    public MethodMissing(Ruby runtimeRubyClass klazz) {
        super(runtimeklazz);
    }
    @JRubyMethod(rest = true)
    public IRubyObject method_missing(IRubyObject[] args) {
        for (IRubyObject arg : args) {
            ..println(arg);
        }
        return getRuntime().getNil();
    }
New to GrepCode? Check out our FAQ X