lib/descendants_describable.rb in descendants_describable-0.0.2 vs lib/descendants_describable.rb in descendants_describable-0.0.3

- old
+ new

@@ -23,16 +23,22 @@ def add_module(mod) self.new_class.send(:include, mod) end def type(name) - self.new_class = Class.new(@parent) + self.new_class = begin + Object.const_get(name.to_s.camelize) + rescue NameError + new_class = Class.new(@parent) + Object.const_set(name.to_s.camelize, new_class) + new_class + end + @common_modules.each { |m| self.new_class.send(:include, m) } if @common_modules.any? yield if block_given? - Object.const_set(name.to_s.camelize, self.new_class) self.new_class = nil end def method_missing(method, *args) if self.new_class.present? \ No newline at end of file