def format_active_record(model)
out = []
out.push format_model_name model
if model.table_exists?
model.columns.each do |column|
out.push format_column column.name, column.type
end
else
out.push format_error "Table doesn't exist"
end
reflections = model.reflections.sort_by do |other_model, reflection|
[reflection.macro.to_s, other_model.to_s]
end
reflections.each do |other_model, reflection|
options = []
if reflection.options[:through].present?
options << "through #{text.blue ":#{reflection.options[:through]}"}"
end
if reflection.options[:class_name].present?
options << "class_name #{text.green ":#{reflection.options[:class_name]}"}"
end
if reflection.options[:foreign_key].present?
options << "foreign_key #{text.red ":#{reflection.options[:foreign_key]}"}"
end
out.push format_association reflection.macro, other_model, options
end
out.join("\n")
end