BasicObject
An inspecting delegator.
Create a trap passing in any object of your choice.
Any time a method is called on the trap, it prints the method name, all its args, and the direct caller.
@example Did you know how basic operators work? Now you do!
trapped_int = ItsATrap.new(3) trapped_int - 55 [:-, [55], nil, "..."] => -52 55 - trapped_int [:coerce, [55], nil, "..."] => 52 - trapped_int [:-@, [], nil, "..."] => -3
# File lib/gorillib/utils/console.rb, line 48 def !@( *args, &block) ; __describe_and_send__(:!, *args, &block) ; end
# File lib/gorillib/utils/console.rb, line 49 def !=( *args, &block) ; __describe_and_send__(:!=, *args, &block) ; end
These are defined on BasicObject, delegate them along with the rest
BasicObject.instance_methods => [:==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]
# File lib/gorillib/utils/console.rb, line 46 def ==( *args, &block) ; __describe_and_send__(:==, *args, &block) ; end
@return the proxied object
# File lib/gorillib/utils/console.rb, line 40 def __obj__ ; @obj ; end
# File lib/gorillib/utils/console.rb, line 47 def equal?(*args, &block) ; __describe_and_send__(:equal?, *args, &block) ; end
We implement to_s and inspect, because otherwise it’s annoyingly noisy. :pretty_inspect makes pry happy.
# File lib/gorillib/utils/console.rb, line 34 def inspect() "~#{@obj.inspect}~" ; end
# File lib/gorillib/utils/console.rb, line 50 def instance_eval(*args, &block) ; __describe_and_send__(:instance_eval, *args, &block) ; end
# File lib/gorillib/utils/console.rb, line 51 def instance_exec(*args, &block) ; __describe_and_send__(:instance_exec, *args, &block) ; end
Generated with the Darkfish Rdoc Generator 2.