Skip to content

Instantly share code, notes, and snippets.

@n00ge
Created August 31, 2012 21:48
Show Gist options
  • Save n00ge/3559604 to your computer and use it in GitHub Desktop.
Save n00ge/3559604 to your computer and use it in GitHub Desktop.
Describe classes (output associations and attributes)
[ClassName].each do |object|
puts "#{object.name} ("
puts "\t# associations"
reflections = object.reflect_on_all_associations
reflections.each do |reflection|
puts "\t#{reflection.macro} => #{reflection.name.to_s.classify}"
end
puts ""
puts "\t# attributes"
object.new.attributes.each do |attribute|
puts "\t#{attribute[0]}"
end
puts ")"
puts ""
puts ""
end;nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment