Robert Klemme wrote:
>>   ALLOWED_MODULES = {
>>     :thing => Thing,
>>   }
>> 
>>   ...
>>     extend ALLOWED_MODULES[mod]
> 
> May I suggest to use #fetch in that case - the error might be a bit more
> telling.

Yes, that's a good idea. I'm in the habit of writing things like

  extend(ALLOWED_MODULES[mod] || (raise "Unknown module 
#{mod.inspect}"))

but I thought that might clutter the sample code in this case. I always 
forget about Hash#fetch.

Another way is:

  ALLOWED_MODULES = Hash.new { raise "Oi!" }
  ALLOWED_MODULES.merge!({
    .. etc
  })
-- 
Posted via http://www.ruby-forum.com/.