def evaluate(instance, &block)
      original_self = eval "self", block.binding

      # A proxy that attemps to make method calls on +instance+. If a NoMethodError is
      # raised, the call will be made on +original_self+.
      proxy = Object.new
      proxy.instance_eval do
        class << self
          attr_accessor :original_self, :instance
        end

        def method_missing(method, *args, &block)
          instance.send(method, *args, &block)
        rescue NoMethodError
          original_self.send(method, *args, &block)
        end
      end

      proxy.instance = instance
      proxy.original_self = original_self

      proxy.instance_eval &block
    end
def evaluate(instance, &block)
      original_self = eval "self", block.binding

      # A proxy that attemps to make method calls on +instance+. If a NoMethodError is
      # raised, the call will be made on +original_self+.
      proxy = Object.new
      proxy.instance_eval do
        class << self
          attr_accessor :original_self, :instance
        end

        def method_missing(method, *args, &block)
          instance.send(method, *args, &block)
        rescue NoMethodError
          original_self.send(method, *args, &block)
        end
      end

      proxy.instance = instance
      proxy.original_self = original_self

      proxy.instance_eval &block
    end
Evaluates a given +block+ inside +instance+. Stores the original block binding.