On 6/13/07, Sharon Phillips <phillipsds / yahoo.co.uk> wrote:


> Here's the method_missing code
>
>    def method_missing style_type, *args
>      case args.size
>        when 1 : @styles [style_type].call(args[0])
>        when 2 : @styles [style_type].call(args[0], args[1])
>      end
>    end
>
>
> I'm sure there's a way for me to get rid of the case statement, but
> if I try
> @styles [style_type].call(args) it just gets sent an array.
>
> Question is, how do I send the contents of the args array?
>
> I realise I should probably have a means of dealing with a genuine
> method_missing. What's the 'ruby way' of doing this? if I call
> method_missing again, wont I end in a recursive mess?

   def method_missing(symbol, *args)
       if prc = @styles[symbol]
            prc.call(*args)
       else
            super
       end
   end


-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/