Issue #3359 has been updated by Kurt  Stephens.


This version is a bit more succinct:

<pre>
 class Date::Format::Bag
    def method_missing(sel, *args) # , &block)
      sel = sel.to_s
      t = sel.dup
      set = t.chomp!('=')
      t = t.intern

      #
      # There appear to be no callers like:
      #
      #   e.foo(something)
      #
      # Thus do not interpret any arguments as
      # the *rest parameter since it creates Arrays 
      # that are never referenced in:
      # 
      #   def foo(*rest); @elem[:foo]; end
      #
      expr = <<"END"
class #{self.class}
  def #{t}(); @elem[#{t.inspect}]; end
  def #{t}=(arg); @elem[#{t.inspect}] = arg; end
end
END
      # $stderr.puts "  **** #{self.class}\##{sel} =>\n#{expr}"
      eval(expr)

      if set
        @elem[t] = args[0]
      else
        @elem[t]
      end
    end
  end
</pre>

----------------------------------------
http://redmine.ruby-lang.org/issues/show/3359

----------------------------------------
http://redmine.ruby-lang.org