lib/rake/funnel/support/internal/instantiate_symbol.rb in rake-funnel-0.11.0.pre vs lib/rake/funnel/support/internal/instantiate_symbol.rb in rake-funnel-0.12.0.pre

- old
+ new

@@ -18,20 +18,25 @@ private def create(sym, *args) return sym unless sym.is_a?(Symbol) - begin - type = self.class.module.const_get(sym) - rescue NameError - raise NameError, "Unknown type to instantiate: #{sym.inspect}. Available types are: #{available.inspect}" - end + found = [sym, sym.pascalize.to_sym] + .select { |candidate| mod.constants.include?(candidate) } + .first + raise NameError, "Unknown type to instantiate: #{sym.inspect}. Available types are: #{available.inspect}" if found.nil? + + type = mod.const_get(found) type.new(*args) end def available - self.class.module.constants.sort + mod.constants.sort + end + + def mod + self.class.module end end end end end