def delegate(method_name, obj, other_method_name = method_name)
      raise ArgumentError, "obj wasn't defined" unless obj
=begin
1.9 only:
      define_method(method_name) do |*args, &block|
        instance_variable_get(obj).__send__(other_method_name, *args, &block)
      end
=end
      obj = obj.to_s
      if obj[0] == ?@
        class_eval <<-EOS
          def #{method_name}(*args, &block)
            instance_variable_get('#{obj}').__send__(
              '#{other_method_name}', *args, &block)
          end
        EOS
      else
        class_eval <<-EOS
          def #{method_name}(*args, &block)
            __send__('#{obj}').__send__(
              '#{other_method_name}', *args, &block)
          end
        EOS
      end
    end
def delegate(method_name, obj, other_method_name = method_name)
      raise ArgumentError, "obj wasn't defined" unless obj
=begin
1.9 only:
      define_method(method_name) do |*args, &block|
        instance_variable_get(obj).__send__(other_method_name, *args, &block)
      end
=end
      obj = obj.to_s
      if obj[0] == ?@
        class_eval <<-EOS
          def #{method_name}(*args, &block)
            instance_variable_get('#{obj}').__send__(
              '#{other_method_name}', *args, &block)
          end
        EOS
      else
        class_eval <<-EOS
          def #{method_name}(*args, &block)
            __send__('#{obj}').__send__(
              '#{other_method_name}', *args, &block)
          end
        EOS
      end
    end
A method to easily delegate methods to an object, stored in an
 instance variable or returned by a method call.

 It's used like this:
   class A
     delegate :method_here, :@obj, :method_there
   end
 or:
   class A
     delegate :method_here, :method_call, :method_there
   end

 _other_method_name_ defaults to method_name, if it wasn't given.