def bound_method(block)
        type = self.type
        arity = block.arity
        arity += 1 if arity >= 0 # Make sure the object gets passed
        arity += 1 if arity == 1 && type == :around  # Make sure the block gets passed
        
        method = if RUBY_VERSION >= '1.9'
          lambda do |object, *args|
            object.instance_exec(*args, &block)
          end
        else
          # Generate a thread-safe unbound method that can be used on any object.
          # This is a workaround for not having Ruby 1.9's instance_exec
          unbound_method = Object.class_eval do
            time = Time.now
            method_name = "__bind_#{time.to_i}_#{time.usec}"
            define_method(method_name, &block)
            method = instance_method(method_name)
            remove_method(method_name)
            method
          end
          
          # Proxy calls to the method so that the method can be bound *and*
          # the arguments are adjusted
          lambda do |object, *args|
            unbound_method.bind(object).call(*args)
          end
        end
        
        # Proxy arity to the original block
        (class << method; self; end).class_eval do
          define_method(:arity) { arity }
        end
        
        method
      end
def bound_method(block)
        type = self.type
        arity = block.arity
        arity += 1 if arity >= 0 # Make sure the object gets passed
        arity += 1 if arity == 1 && type == :around  # Make sure the block gets passed
        
        method = if RUBY_VERSION >= '1.9'
          lambda do |object, *args|
            object.instance_exec(*args, &block)
          end
        else
          # Generate a thread-safe unbound method that can be used on any object.
          # This is a workaround for not having Ruby 1.9's instance_exec
          unbound_method = Object.class_eval do
            time = Time.now
            method_name = "__bind_#{time.to_i}_#{time.usec}"
            define_method(method_name, &block)
            method = instance_method(method_name)
            remove_method(method_name)
            method
          end
          
          # Proxy calls to the method so that the method can be bound *and*
          # the arguments are adjusted
          lambda do |object, *args|
            unbound_method.bind(object).call(*args)
          end
        end
        
        # Proxy arity to the original block
        (class << method; self; end).class_eval do
          define_method(:arity) { arity }
        end
        
        method
      end
Generates a method that can be bound to the object being transitioned
 when the callback is invoked