Class: Dbmapper::DatabaseMapper
- Inherits:
-
Object
- Object
- Dbmapper::DatabaseMapper
- Defined in:
- lib/dbmapper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #all_columns ⇒ Object
- #all_models ⇒ Object
- #all_models_with_association ⇒ Object
- #initlialize ⇒ Object
Class Method Details
.hello_world ⇒ Object
6 7 8 |
# File 'lib/dbmapper.rb', line 6 def self.hello_world puts "Hello World" end |
Instance Method Details
#all_columns ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dbmapper.rb', line 22 def all_columns #open file text_file = File.open("mapped_databse.txt", 'w') ActiveRecord::Base.descendants.each do |model| text_file.write(model); model.column_names.each do |column| text_file.write(column) end end end |
#all_models ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/dbmapper.rb', line 13 def all_models #open file text_file = File.open("mapped_databse.txt", 'w') ActiveRecord::Base.descendants.each do |model| text_file.write(model) end text_file.close end |
#all_models_with_association ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dbmapper.rb', line 33 def all_models_with_association #open file text_file = File.open("mapped_databse.txt", 'w') association_string = "-->" ActiveRecord::Base.descendants.each do |model| text_file.write(model) model.relfect_on_all_associations.map(&:name).each do |assocations| association_string = association_string + " #{assocations}," end text_file.write(association_string) association_string = "-->" end text_file.close end |
#initlialize ⇒ Object
9 10 11 |
# File 'lib/dbmapper.rb', line 9 def initlialize Rails.application.eager_load! end |