Sha256: 10490f54fbc4633417c926d92c2a02a9b20474e0371205dc4ca73c6955adc60e
Contents?: true
Size: 738 Bytes
Versions: 5
Compression:
Stored size: 738 Bytes
Contents
module Rake::Funnel::Support module InstantiateSymbol def self.included(klass) klass.extend(ClassMethods) klass.send(:instantiate, klass) end module ClassMethods attr_reader :module private def instantiate(mod) @module = mod end end private def create(sym, *args) return sym unless sym.kind_of?(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 type.new(*args) end def available return self.class.module.constants.sort end end end
Version data entries
5 entries across 5 versions & 1 rubygems