lib/ar2gostruct/converter.rb in ar2gostruct-0.2.0 vs lib/ar2gostruct/converter.rb in ar2gostruct-0.2.1

- old
+ new

@@ -74,14 +74,29 @@ [assoc_max_size, type_max_size].max end def get_orm_options(col) tags ||= [] - builder = "Ar2gostruct::Builder::ORM::#{self.orm.upcase}".constantize.new(self.klass) - option = builder.get_option col - tags << option if option + self.orm.split(",").each do |orm_name| + builder = get_orm_builder orm_name + if builder + option = builder.get_option col + tags << option if option + end + end + return tags rescue => e [] + end + + def get_orm_builder(orm_name) + prefix = "Ar2gostruct::Builder::ORM::" + builder = if Object.const_defined?("#{prefix}#{orm_name.upcase}") + "#{prefix}#{orm_name.upcase}" + elsif Object.const_defined?("#{prefix}#{orm_name.camelize}") + "#{prefix}#{orm_name.camelize}" + end + return builder.constantize.new(self.klass) if builder end def get_struct_name if self.plural self.klass.table_name.camelize \ No newline at end of file