lib/activefacts/api/vocabulary.rb in activefacts-api-1.9.5 vs lib/activefacts/api/vocabulary.rb in activefacts-api-1.9.6

- old
+ new

@@ -30,12 +30,18 @@ camel = name.to_s.camelcase if (c = @object_type[camel]) __bind(camel) c else - klass = const_get(camel) rescue nil # NameError if undefined - klass && klass.modspace == self ? klass : nil + if constants.include?(camel.to_sym) + if klass = const_get(camel) and !klass.respond_to?(:vocabulary) + raise CrossVocabularyRoleException.new(name, self) + end + klass + else + nil + end end end # Create a new constellation over this vocabulary def constellation @@ -47,14 +53,14 @@ end def verbalise "Vocabulary #{name}:\n\t" + @object_type.keys.sort.map do |object_type| - c = @object_type[object_type] - __bind(c.basename) - c.verbalise + "\n\t\t// Roles played: " + c.all_role.verbalise - end. - join("\n\t") + c = @object_type[object_type] + __bind(c.basename) + c.verbalise + "\n\t\t// Roles played: " + c.all_role.verbalise + end. + join("\n\t") end def __add_object_type(klass) #:nodoc: name = klass.basename __bind(name)