# File lib/state_machine/eval_helpers.rb, line 53
    def evaluate_method(object, method, *args, &block)
      case method
        when Symbol
          object.method(method).arity == 0 ? object.send(method, &block) : object.send(method, *args, &block)
        when Proc, Method
          args.unshift(object)
          arity = method.arity
          limit = [0, 1].include?(arity) ? arity : args.length
          
          # Procs don't support blocks in < Ruby 1.8.6, so it's tacked on as an
          # argument for consistency across versions of Ruby (even though 1.9
          # supports yielding within blocks)
          if block_given? && Proc === method && arity != 0
            if [1, 2].include?(arity)
              # Force the block to be either the only argument or the 2nd one
              # after the object (may mean additional arguments get discarded)
              limit = arity
              args.insert(limit - 1, block)
            else
              # Tack the block to the end of the args
              limit += 1 unless limit < 0
              args.push(block)
            end
          end
          
          method.call(*args[0, limit], &block)
        when String
          eval(method, object.instance_eval {binding}, &block)
        else
          raise ArgumentError, 'Methods must be a symbol denoting the method to call, a block to be invoked, or a string to be evaluated'
        end
    end