I have this method in module:

  def text_field_tag(*args)
    args.push(nil) if args.length == 1

    args.push({}) if args.length == 2
    args.last['class'] ||= 'text_field_tag' if args.last.kind_of? Hash
    super(*args)
  end

It works fine, the problem is that I need to define lots of these 
methods.

I tried using:

  def class_extendor(*args)
    args.each do |arg|
      define_method(name) do |*args|
        args.push(nil) if args.length == 1

        args.push({}) if args.length == 2
        args.last['class'] ||= name if args.last.kind_of? Hash
        super(*args)
      end
    end
  end

  class_extendor "text_field_tag", "text_field_tag2"

but it doesn't work (no wonders why...)

Anyway, ideas how to implement that?

-- 
Posted via http://www.ruby-forum.com/.