Permalink
Browse files

Whoops!

  • Loading branch information...
1 parent 4a8da22 commit 45bcfb4f3533691c8b2126e709ecf018b4ea2a9d Yehuda Katz committed Nov 30, 2009
Showing with 35 additions and 0 deletions.
  1. +35 −0 irb/proxy.rb
View
@@ -0,0 +1,35 @@
+# if !defined?(BasicObject)
+ class BlankSlate < Object
+ instance_methods.each do |name|
+ undef_method name unless name.to_s =~ /__id__|object_id|__send__|instance_eval/
+ end
+ end
+# end
+
+module IRB
+ class Proxy < BlankSlate
+ def initialize(object)
+ @object = object
+ ExtendCommandBundle.extend_object(self)
+ end
+
+ def exit
+ throw(:irb_exit)
+ end
+
+ def inspect
+ $DEBUG ? "proxy for #{@object}" : @object.inspect
+ end
+
+ def extend(*args)
+ end
+
+ def method_missing(meth, *args, &block)
+ if @object.public_methods.any? {|m| m.to_s == meth.to_s }
+ @object.__send__(meth, *args, &block)
+ else
+ @object.__send__(:method_missing, meth, *args, &block)
+ end
+ end
+ end
+end

0 comments on commit 45bcfb4

Please sign in to comment.