1 30 package org.jruby.internal.runtime.methods; 31 32 import org.jruby.Ruby; 33 import org.jruby.RubyModule; 34 import org.jruby.RubyUnboundMethod; 35 import org.jruby.runtime.Block; 36 import org.jruby.runtime.ThreadContext; 37 import org.jruby.runtime.Visibility; 38 import org.jruby.runtime.builtin.IRubyObject; 39 40 44 public class MethodMethod extends DynamicMethod { 45 private RubyUnboundMethod method; 46 47 51 public MethodMethod(RubyModule implementationClass, RubyUnboundMethod method, Visibility visibility) { 52 super(implementationClass, visibility); 53 this.method = method; 54 } 55 56 public void preMethod(ThreadContext context, RubyModule klazz, IRubyObject self, String name, IRubyObject[] args, boolean noSuper, Block block) { 57 context.preMethodCall(implementationClass, klazz, self, name, args, block, noSuper); 58 } 59 60 public void postMethod(ThreadContext context) { 61 context.postMethodCall(); 62 } 63 64 67 public IRubyObject internalCall(ThreadContext context, RubyModule klazz, IRubyObject self, String name, IRubyObject[] args, boolean noSuper, Block block) { 68 return method.bind(self, block).call(args, block); 69 } 70 71 public DynamicMethod dup() { 72 return new MethodMethod(getImplementationClass(), method, getVisibility()); 73 } 74 } 75 | Popular Tags |