Class: Dbmapper::DatabaseMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/dbmapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hello_worldObject



6
7
8
# File 'lib/dbmapper.rb', line 6

def self.hello_world
  puts "Hello World"
end

Instance Method Details

#all_columnsObject



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_modelsObject



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_associationObject



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

#initlializeObject



9
10
11
# File 'lib/dbmapper.rb', line 9

def initlialize
  Rails.application.eager_load!
end