class WebTools::Support::Debugger::Frame::Context

Emulates the context of a frame execution Defines accessors to the frame locals and sets the instance variables to point to the original object's values

Public Class Methods

create_for(frame, receiver, context_hash) click to toggle source

Tries to create a duplicate of the receiver. If that is not possible, creates a new instance of self. In any case, a singleton class is added to define accessors to frame local values

# File lib/web_tools/support/debugger.rb, line 255
def self.create_for(frame, receiver, context_hash)
  rcv = nil
  begin
    rcv = receiver.dup
  rescue Exception
  end
  if receiver === rcv || rcv.nil?
    rcv = self.new(receiver)

    receiver.instance_variables do |name|
      rcv.instance_variable_set(name, receiver.instance_variable_get(name))
    end

    receiver_mod = (receiver.is_a?(Module) ? receiver : receiver.class)
    receiver_mod.constants do |sym|
      rcv.singleton_class.const_set(sym, receiver_mod.const_get(sym))
    end
  end

  context_hash.each do |k,v|
    next if [:"(self)", :"(class)", :"(receiver)"].include? k
    rcv.singleton_class.define_method(:"#{k}") { v }
    rcv.singleton_class.define_method(:"#{k}=") do |v|
      frame.thread.__frame_at_temp_named_put(frame.index, k, v)
    end
  end
  rcv
end
new(rcv) click to toggle source
# File lib/web_tools/support/debugger.rb, line 284
def initialize(rcv)
  @receiver = rcv
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
# File lib/web_tools/support/debugger.rb, line 296
def method_missing(method, *args, &block)
  @receiver.send(method, *args, &block)
end
myself() click to toggle source
# File lib/web_tools/support/debugger.rb, line 288
def myself
  @receiver
end
respond_to?(method) click to toggle source
# File lib/web_tools/support/debugger.rb, line 292
def respond_to?(method)
  @receiver.respond_to? method
end