Module: Jackbox::Examples::DX
- Defined in:
- lib/jackbox/examples/dx.rb
Overview
Debugging Extras
Class Attribute Summary collapse
-
.tracer ⇒ Object
Returns the value of attribute tracer.
Class Method Summary collapse
Class Attribute Details
.tracer ⇒ Object
Returns the value of attribute tracer.
124 125 126 |
# File 'lib/jackbox/examples/dx.rb', line 124 def tracer @tracer end |
Class Method Details
.wrap(klass, method) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/jackbox/examples/dx.rb', line 145 def wrap(klass, method) klass.instance_eval do method_object = instance_method(method) define_method(method) do |*args, &block| DX.tracer = Fiber.new do |binding| Fiber.yield lnames, inames = binding.eval("local_variables"), binding.eval("instance_variables") lvars, ivars = [lnames, inames].map{ |names| names.inject({}) { |vars, name| vars[name] = binding.eval(name.to_s) and vars } rescue nil } @_trace = %{ -local variables: #{lvars}\n -instance variables: #{ivars}\n } end result = method_object.bind(self).call(*args, &block) end end end |