Parent

Class/Module Index [+]

Quicksearch

ItsATrap

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

Public Class Methods

new(obj=::Object.new, show_ret=false) click to toggle source
# File lib/gorillib/utils/console.rb, line 26
def initialize(obj=::Object.new, show_ret=false)
  @obj        = obj
  @call_count = 0
  @show_ret   = show_ret
end

Public Instance Methods

!(@( *args, &block) ;) click to toggle source
# File lib/gorillib/utils/console.rb, line 48
def !@(    *args, &block)        ; __describe_and_send__(:!,      *args, &block) ; end
!=( *args, &block) click to toggle source
# File lib/gorillib/utils/console.rb, line 49
def !=(    *args, &block)        ; __describe_and_send__(:!=,     *args, &block) ; end
==( *args, &block) click to toggle source

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
__obj__() click to toggle source

@return the proxied object

# File lib/gorillib/utils/console.rb, line 40
def __obj__ ; @obj ; end
equal?(*args, &block) click to toggle source
# File lib/gorillib/utils/console.rb, line 47
def equal?(*args, &block)        ; __describe_and_send__(:equal?, *args, &block) ; end
inspect() click to toggle source

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
Also aliased as: pretty_inspect
instance_eval(*args, &block) click to toggle source
# File lib/gorillib/utils/console.rb, line 50
def instance_eval(*args, &block) ; __describe_and_send__(:instance_eval, *args, &block) ; end
instance_exec(*args, &block) click to toggle source
# File lib/gorillib/utils/console.rb, line 51
def instance_exec(*args, &block) ; __describe_and_send__(:instance_exec, *args, &block) ; end
methods() click to toggle source
# File lib/gorillib/utils/console.rb, line 37
def methods() @obj.methods ; end
pretty_inspect() click to toggle source
Alias for: inspect
to_s() click to toggle source
# File lib/gorillib/utils/console.rb, line 35
def to_s()    @obj.to_s        ; end

[Validate]

Generated with the Darkfish Rdoc Generator 2.