gdonald-railsdb 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/LICENSE.txt +674 -0
  2. data/README.txt +40 -0
  3. data/README_RAILS.txt +204 -0
  4. data/Rakefile +31 -0
  5. data/app/controllers/application.rb +24 -0
  6. data/app/controllers/database_controller.rb +274 -0
  7. data/app/controllers/home_controller.rb +366 -0
  8. data/app/helpers/application_helper.rb +43 -0
  9. data/app/helpers/home_helper.rb +2 -0
  10. data/app/models/database.rb +113 -0
  11. data/app/models/driver.rb +8 -0
  12. data/app/models/field.rb +117 -0
  13. data/app/models/group.rb +12 -0
  14. data/app/models/group_permission.rb +6 -0
  15. data/app/models/permission.rb +9 -0
  16. data/app/models/row.rb +26 -0
  17. data/app/models/switch.rb +85 -0
  18. data/app/models/table.rb +155 -0
  19. data/app/models/user.rb +98 -0
  20. data/app/models/user_group.rb +6 -0
  21. data/app/views/database/_field.html.erb +20 -0
  22. data/app/views/database/_field_form.html.erb +28 -0
  23. data/app/views/database/_insert_form.html.erb +37 -0
  24. data/app/views/database/_new_field.html.erb +43 -0
  25. data/app/views/database/_new_field_header.html.erb +12 -0
  26. data/app/views/database/_pagination.html.erb +14 -0
  27. data/app/views/database/_row.html.erb +16 -0
  28. data/app/views/database/_table.html.erb +22 -0
  29. data/app/views/database/_table_form.html.erb +45 -0
  30. data/app/views/database/add_fields.html.erb +3 -0
  31. data/app/views/database/add_table.html.erb +3 -0
  32. data/app/views/database/blank_field.rjs +6 -0
  33. data/app/views/database/browse.html.erb +30 -0
  34. data/app/views/database/del_field.html.erb +31 -0
  35. data/app/views/database/del_table.html.erb +31 -0
  36. data/app/views/database/edit_field.html.erb +23 -0
  37. data/app/views/database/edit_row.html.erb +22 -0
  38. data/app/views/database/index.html.erb +23 -0
  39. data/app/views/database/insert.html.erb +3 -0
  40. data/app/views/database/table.html.erb +30 -0
  41. data/app/views/home/_database.html.erb +8 -0
  42. data/app/views/home/_database_form.html.erb +68 -0
  43. data/app/views/home/_driver.html.erb +5 -0
  44. data/app/views/home/_driver_form.html.erb +25 -0
  45. data/app/views/home/_group.html.erb +10 -0
  46. data/app/views/home/_group_form.html.erb +25 -0
  47. data/app/views/home/_group_permission.html.erb +4 -0
  48. data/app/views/home/_permission.html.erb +6 -0
  49. data/app/views/home/_permission_form.html.erb +32 -0
  50. data/app/views/home/_user.html.erb +10 -0
  51. data/app/views/home/_user_form.html.erb +64 -0
  52. data/app/views/home/_user_group.html.erb +4 -0
  53. data/app/views/home/add_database.html.erb +3 -0
  54. data/app/views/home/add_driver.html.erb +3 -0
  55. data/app/views/home/add_group.html.erb +4 -0
  56. data/app/views/home/add_permission.html.erb +3 -0
  57. data/app/views/home/add_user.html.erb +62 -0
  58. data/app/views/home/bottom.html.erb +17 -0
  59. data/app/views/home/databases.html.erb +22 -0
  60. data/app/views/home/del_database.html.erb +31 -0
  61. data/app/views/home/del_driver.html.erb +32 -0
  62. data/app/views/home/del_group.html.erb +32 -0
  63. data/app/views/home/del_group_permission.html.erb +32 -0
  64. data/app/views/home/del_permission.html.erb +32 -0
  65. data/app/views/home/del_user.html.erb +33 -0
  66. data/app/views/home/del_user_group.html.erb +32 -0
  67. data/app/views/home/drivers.html.erb +20 -0
  68. data/app/views/home/edit_database.html.erb +3 -0
  69. data/app/views/home/edit_driver.html.erb +3 -0
  70. data/app/views/home/edit_group.html.erb +4 -0
  71. data/app/views/home/edit_permission.html.erb +4 -0
  72. data/app/views/home/edit_user.html.erb +84 -0
  73. data/app/views/home/group_permissions.html.erb +38 -0
  74. data/app/views/home/groups.html.erb +20 -0
  75. data/app/views/home/index.html.erb +21 -0
  76. data/app/views/home/login.html.erb +42 -0
  77. data/app/views/home/menu.html.erb +33 -0
  78. data/app/views/home/permissions.html.erb +21 -0
  79. data/app/views/home/top.html.erb +22 -0
  80. data/app/views/home/user_groups.html.erb +44 -0
  81. data/app/views/home/users.html.erb +27 -0
  82. data/app/views/layouts/application.html.erb +18 -0
  83. data/config/boot.rb +109 -0
  84. data/config/database.yml +14 -0
  85. data/config/environment.rb +114 -0
  86. data/config/environments/development.rb +18 -0
  87. data/config/environments/production.rb +19 -0
  88. data/config/environments/test.rb +22 -0
  89. data/config/initializers/inflections.rb +10 -0
  90. data/config/initializers/mime_types.rb +5 -0
  91. data/config/routes.rb +135 -0
  92. data/db/migrate/001_create_sessions.rb +17 -0
  93. data/db/migrate/002_create_users.rb +26 -0
  94. data/db/migrate/003_create_groups.rb +17 -0
  95. data/db/migrate/004_create_permissions.rb +18 -0
  96. data/db/migrate/005_create_group_permissions.rb +22 -0
  97. data/db/migrate/006_create_user_groups.rb +19 -0
  98. data/db/migrate/007_create_drivers.rb +17 -0
  99. data/db/migrate/008_create_databases.rb +43 -0
  100. data/db/schema.rb +91 -0
  101. data/lib/ignore +0 -0
  102. data/log/ignore +0 -0
  103. data/public/404.html +30 -0
  104. data/public/422.html +30 -0
  105. data/public/500.html +30 -0
  106. data/public/dispatch.cgi +10 -0
  107. data/public/dispatch.fcgi +24 -0
  108. data/public/dispatch.rb +10 -0
  109. data/public/favicon.ico +0 -0
  110. data/public/images/rails.png +0 -0
  111. data/public/images/ss1.png +0 -0
  112. data/public/images/ss2.png +0 -0
  113. data/public/images/ss3.png +0 -0
  114. data/public/images/ss4.png +0 -0
  115. data/public/images/ss5.png +0 -0
  116. data/public/images/ss6.png +0 -0
  117. data/public/javascripts/application.js +25 -0
  118. data/public/javascripts/controls.js +963 -0
  119. data/public/javascripts/dragdrop.js +972 -0
  120. data/public/javascripts/effects.js +1120 -0
  121. data/public/javascripts/prototype.js +4225 -0
  122. data/public/robots.txt +4 -0
  123. data/public/stylesheets/railsdb.css +227 -0
  124. data/script/about +3 -0
  125. data/script/console +3 -0
  126. data/script/destroy +3 -0
  127. data/script/generate +3 -0
  128. data/script/performance/benchmarker +3 -0
  129. data/script/performance/profiler +3 -0
  130. data/script/performance/request +3 -0
  131. data/script/plugin +3 -0
  132. data/script/process/inspector +3 -0
  133. data/script/process/reaper +3 -0
  134. data/script/process/spawner +3 -0
  135. data/script/runner +3 -0
  136. data/script/server +3 -0
  137. data/test/fixtures/databases.yml +7 -0
  138. data/test/fixtures/drivers.yml +7 -0
  139. data/test/fixtures/group_permissions.yml +7 -0
  140. data/test/fixtures/groups.yml +7 -0
  141. data/test/fixtures/permissions.yml +7 -0
  142. data/test/fixtures/user_groups.yml +7 -0
  143. data/test/fixtures/users.yml +18 -0
  144. data/test/functional/home_controller_test.rb +8 -0
  145. data/test/test_helper.rb +38 -0
  146. data/test/unit/database_test.rb +8 -0
  147. data/test/unit/driver_test.rb +8 -0
  148. data/test/unit/group_permission_test.rb +8 -0
  149. data/test/unit/group_test.rb +8 -0
  150. data/test/unit/permission_test.rb +8 -0
  151. data/test/unit/user_group_test.rb +8 -0
  152. data/test/unit/user_test.rb +9 -0
  153. data/tmp/pids/ignore +0 -0
  154. data/tmp/sessions/ignore +0 -0
  155. data/tmp/sockets/ignore +0 -0
  156. metadata +287 -0
@@ -0,0 +1,366 @@
1
+ class HomeController < ApplicationController
2
+
3
+ before_filter :check_perm, :except => [ :login, :logout ]
4
+
5
+ filter_parameter_logging :password
6
+
7
+ layout :get_layout
8
+
9
+ def index
10
+ end
11
+
12
+ def top
13
+ end
14
+
15
+ def menu
16
+ end
17
+
18
+ def bottom
19
+ end
20
+
21
+ def databases
22
+ @databases = Database.find( :all, :order => 'name' )
23
+ end
24
+
25
+ def add_database
26
+ @database = Database.new
27
+ if request.post?
28
+ @database = Database.new( params[:database] )
29
+ @database.save
30
+ unless @database.new_record?
31
+ flash[:notice] = 'new database added'
32
+ redirect_to :controller => 'home', :action => 'databases'
33
+ end
34
+ end
35
+ end
36
+
37
+ def edit_database
38
+ get_database params[:id]
39
+ if request.post?
40
+ if @database.update_attributes( params[:database] )
41
+ flash[:notice] = 'database updated'
42
+ redirect_to :controller => 'home', :action => 'databases'
43
+ end
44
+ end
45
+ end
46
+
47
+ def del_database
48
+ get_database params[:id]
49
+ if request.post?
50
+ @database.destroy
51
+ flash[:notice] = 'database deleted'
52
+ redirect_to :controller => 'home', :action => 'databases'
53
+ end
54
+ end
55
+
56
+ def drivers
57
+ @drivers = Driver.find( :all, :order => 'name' )
58
+ end
59
+
60
+ def add_driver
61
+ @driver = Driver.new
62
+ if request.post?
63
+ @driver = Driver.new( params[:driver] )
64
+ @driver.save
65
+ unless @driver.new_record?
66
+ flash[:notice] = 'new driver added'
67
+ redirect_to :controller => 'home', :action => 'drivers'
68
+ end
69
+ end
70
+ end
71
+
72
+ def edit_driver
73
+ get_driver params[:id]
74
+ if request.post?
75
+ if @driver.update_attributes( params[:driver] )
76
+ flash[:notice] = 'driver updated'
77
+ redirect_to :controller => 'home', :action => 'drivers'
78
+ end
79
+ end
80
+ end
81
+
82
+ def del_driver
83
+ get_driver params[:id]
84
+ if request.post?
85
+ @driver.destroy
86
+ flash[:notice] = 'driver deleted'
87
+ redirect_to :controller => 'home', :action => 'drivers'
88
+ end
89
+ end
90
+
91
+ def group_permissions
92
+ get_group params[:id]
93
+ @group_permissions = @group.group_permissions
94
+ pids = @group_permissions.collect { |p| p.permission_id }
95
+ @permissions = []
96
+ Permission.find( :all, :order => 'name' ).each do |p|
97
+ @permissions << p unless pids.include? p.id
98
+ end
99
+ end
100
+
101
+ def add_group_permission
102
+ get_group params[:group_id]
103
+ permission = Permission.find( :first, :conditions => [ 'id = ?', params[:permission_id] ] )
104
+ if permission.nil?
105
+ flash[:notice] = 'permission not found'
106
+ redirect_to :controller => 'home', :action => 'group_permissions', :id => @group.id
107
+ end
108
+ if @group.group_permissions.include? permission
109
+ flash[:notice] = 'permission already exists'
110
+ else
111
+ @group.permissions << permission
112
+ flash[:notice] = 'new permission added'
113
+ end
114
+ redirect_to :controller => 'home', :action => 'group_permissions', :id => @group.id
115
+ end
116
+
117
+ def del_group_permission
118
+ @group_permission = GroupPermission.find( :first, :conditions => [ 'id = ?', params[:id] ] )
119
+ @group = @group_permission.group
120
+ @permission = @group_permission.permission
121
+ if request.post?
122
+ @group_permission.destroy
123
+ flash[:notice] = 'group permission deleted'
124
+ redirect_to :controller => 'home', :action => 'group_permissions', :id => @group.id
125
+ end
126
+ end
127
+
128
+ def user_groups
129
+ get_user params[:id]
130
+ @user_groups = @user.user_groups
131
+ gids = @user_groups.collect { |g| g.group_id }
132
+ @groups = []
133
+ Group.find( :all, :order => 'name' ).each do |g|
134
+ @groups << g unless gids.include? g.id
135
+ end
136
+ end
137
+
138
+ def add_user_group
139
+ get_user params[:user_id]
140
+ group = Group.find( :first, :conditions => [ 'id = ?', params[:group_id] ] )
141
+ if group.nil?
142
+ flash[:notice] = 'group not found'
143
+ redirect_to :controller => 'home', :action => 'user_groups', :id => @user.id
144
+ end
145
+ if @user.user_groups.include? group
146
+ flash[:notice] = 'group already exists'
147
+ else
148
+ @user.groups << group
149
+ flash[:notice] = 'new group added'
150
+ end
151
+ redirect_to :controller => 'home', :action => 'user_groups', :id => @user.id
152
+ end
153
+
154
+ def del_user_group
155
+ @user_group = UserGroup.find( :first, :conditions => [ 'id = ?', params[:id] ] )
156
+ user = @user_group.user
157
+ if request.post?
158
+ @user_group.destroy
159
+ flash[:notice] = 'user group deleted'
160
+ redirect_to :controller => 'home', :action => 'user_groups', :id => user.id
161
+ end
162
+ end
163
+
164
+ def permissions
165
+ @permissions = Permission.find( :all, :order => 'name' )
166
+ end
167
+
168
+ def add_permission
169
+ @permission = Permission.new
170
+ if request.post?
171
+ @permission = Permission.new( params[:permission] )
172
+ @permission.save
173
+ unless @permission.new_record?
174
+ flash[:notice] = 'new permission added'
175
+ redirect_to :controller => 'home', :action => 'permissions'
176
+ end
177
+ end
178
+ end
179
+
180
+ def edit_permission
181
+ get_permission params[:id]
182
+ if request.post?
183
+ if @permission.update_attributes( params[:permission] )
184
+ flash[:notice] = 'permission updated'
185
+ redirect_to :controller => 'home', :action => 'permissions'
186
+ end
187
+ end
188
+ end
189
+
190
+ def del_permission
191
+ get_permission params[:id]
192
+ if request.post?
193
+ @permission.destroy
194
+ flash[:notice] = 'permission deleted'
195
+ redirect_to :controller => 'home', :action => 'permissions'
196
+ end
197
+ end
198
+
199
+ def groups
200
+ @groups = Group.find( :all, :order => 'name' )
201
+ end
202
+
203
+ def add_group
204
+ @group = Group.new
205
+ if request.post?
206
+ @group = Group.new( params[:group] )
207
+ @group.save
208
+ unless @group.new_record?
209
+ flash[:notice] = 'new group added'
210
+ redirect_to :controller => 'home', :action => 'groups'
211
+ end
212
+ end
213
+ end
214
+
215
+ def edit_group
216
+ get_group params[:id]
217
+ if request.post?
218
+ if @group.update_attributes( params[:group] )
219
+ flash[:notice] = 'group updated'
220
+ redirect_to :controller => 'home', :action => 'groups'
221
+ end
222
+ end
223
+ end
224
+
225
+ def del_group
226
+ get_group params[:id]
227
+ if request.post?
228
+ @group.destroy
229
+ flash[:notice] = 'group deleted'
230
+ redirect_to :controller => 'home', :action => 'groups'
231
+ end
232
+ end
233
+
234
+ def users
235
+ @users = User.find( :all, :order => 'lname,fname' )
236
+ end
237
+
238
+ def add_user
239
+ @user = User.new
240
+ if request.post?
241
+ @user = User.new( params[:user] )
242
+ @user.save
243
+ unless @user.new_record?
244
+ flash[:notice] = 'new user added'
245
+ redirect_to :controller => 'home', :action => 'users'
246
+ end
247
+ end
248
+ end
249
+
250
+ def edit_user
251
+ get_user params[:id]
252
+ if request.post?
253
+ #TODO: validate the fields below
254
+ @user2 = User.find_by_email( params[:user][:email] )
255
+ if @user2.nil? || @user2.id == @user.id
256
+ @user.update_attribute( 'email', params[:user][:email] )
257
+ end
258
+ @user.update_attribute( 'fname', params[:user][:fname] )
259
+ @user.update_attribute( 'lname', params[:user][:lname] )
260
+ @user.update_attribute( 'username', params[:user][:username] )
261
+ flash[:notice] = 'user updated'
262
+ redirect_to :controller => 'home', :action => 'users'
263
+ end
264
+ end
265
+
266
+ def update_pass
267
+ get_user params[:user][:id]
268
+ if request.post?
269
+ #TODO: make password validation work from inside model
270
+ if params[:user][:password] == params[:user][:password_confirmation]
271
+ passwd_salt = User.salt
272
+ @user.update_attribute( 'passwd_salt', passwd_salt )
273
+ passwd_hash = User.hash_password( params[:user][:password], passwd_salt )
274
+ @user.update_attribute( 'passwd_hash', passwd_hash )
275
+ flash[:notice] = 'password updated'
276
+ redirect_to :controller => 'home', :action => 'users'
277
+ else
278
+ @user.errors.add( 'password_confirmation', 'passwords must match' )
279
+ end
280
+ end
281
+ end
282
+
283
+ def del_user
284
+ get_user params[:id]
285
+ if request.post?
286
+ @user.destroy
287
+ flash[:notice] = 'user deleted'
288
+ redirect_to :controller => 'home', :action => 'users'
289
+ end
290
+ end
291
+
292
+ def login
293
+ session[:user_id] = nil
294
+ if request.post?
295
+ user = User.authenticate( params[:login][:username], params[:login][:password] )
296
+ if user
297
+ session[:user_id] = user.id
298
+ uri = session[:uri]
299
+ session[:uri] = nil
300
+ flash[:notice] = 'login successful'
301
+ redirect_to uri || { :controller => 'home' }
302
+ else
303
+ flash[:notice] = 'login failed'
304
+ end
305
+ end
306
+ end
307
+
308
+ def logout
309
+ reset_session
310
+ redirect_to :controller => :home, :action => :login
311
+ end
312
+
313
+ private
314
+
315
+ def check_perm
316
+ unless check_site_perm 'admin'
317
+ flash[:notice] = 'please login'
318
+ redirect_to :controller => 'home', :action => 'login'
319
+ end
320
+ end
321
+
322
+ def get_user( id )
323
+ @user = User.find( :first, :conditions => [ 'id = ?', id ] )
324
+ if @user.nil?
325
+ flash[:notice] = 'user not found'
326
+ redirect_to :controller => 'home', :action => 'users'
327
+ end
328
+ end
329
+
330
+ def get_group( id )
331
+ @group = Group.find( :first, :conditions => [ 'id = ?', id ] )
332
+ if @group.nil?
333
+ flash[:notice] = 'group not found'
334
+ redirect_to :controller => 'home', :action => 'groups'
335
+ end
336
+ end
337
+
338
+ def get_permission( id )
339
+ @permission = Permission.find( :first, :conditions => [ 'id = ?', id ] )
340
+ if @permission.nil?
341
+ flash[:notice] = 'permission not found'
342
+ redirect_to :controller => 'home', :action => 'permissions'
343
+ end
344
+ end
345
+
346
+ def get_driver( id )
347
+ @driver = Driver.find( :first, :conditions => [ 'id = ?', id ] )
348
+ if @driver.nil?
349
+ flash[:notice] = 'driver not found'
350
+ redirect_to :controller => 'home', :action => 'drivers'
351
+ end
352
+ end
353
+
354
+ def get_database( id )
355
+ @database = Database.find( :first, :conditions => [ 'id = ?', id ] )
356
+ if @database.nil?
357
+ flash[:notice] = "database &quot;#{ database }&quot; not found";
358
+ redirect_to :controller => :home, :action => :databases
359
+ end
360
+ end
361
+
362
+ def get_layout
363
+ ( %w( index top menu bottom login ).include? self.action_name ) ? nil : 'application'
364
+ end
365
+
366
+ end
@@ -0,0 +1,43 @@
1
+ module ApplicationHelper
2
+
3
+ #
4
+ # Override @page_title in the view, otheriwse the page
5
+ # gets named 'Home'.
6
+ #
7
+ def page_title
8
+ @page_title || 'Home'
9
+ end
10
+
11
+ #
12
+ # Alternating row style setter
13
+ #
14
+ def alt( s='', s2='2')
15
+ " class='alt#{ cycle( s, s2 ) }'"
16
+ end
17
+
18
+ #
19
+ # Paginate the rows
20
+ #
21
+ def row_pagination( total_pages )
22
+ render :partial => "database/pagination" if total_pages > 1
23
+ end
24
+
25
+ #
26
+ # This method Accepts a String or an Array of options and always
27
+ # includes a blank options.
28
+ #
29
+ def get_options( options, selected )
30
+ options = options_for_select( options, selected.to_s ) if options.class == Array
31
+ "<option value=''></option>#{ options }"
32
+ end
33
+
34
+ #
35
+ # Collection of table type options appropriate for passing to
36
+ # ActionView::Helpers::FormOptionsHelper.options_for_select
37
+ #
38
+ def field_type_options( driver )
39
+ field_types = get_field_types( driver )
40
+ field_types.collect { |ft| [ ft, ft ] }
41
+ end
42
+
43
+ end
@@ -0,0 +1,2 @@
1
+ module HomeHelper
2
+ end
@@ -0,0 +1,113 @@
1
+ class Database < ActiveRecord::Base
2
+
3
+ include Switch
4
+
5
+ belongs_to :driver
6
+
7
+ validates_presence_of :driver_id,
8
+ :message => 'driver type required'
9
+
10
+ validates_presence_of :name,
11
+ :message => 'name required'
12
+
13
+ validates_length_of :name,
14
+ :maximum => 64,
15
+ :message => 'must be less than %d characters in length'
16
+
17
+ validates_presence_of :path,
18
+ :allow_nil => true,
19
+ :if => Proc.new { |database| database.driver && database.driver.name == 'sqlite3' },
20
+ :message => 'file path required for sqlite3'
21
+
22
+ validates_length_of :path,
23
+ :maximum => 255,
24
+ :allow_nil => true,
25
+ :message => 'must be less than %d characters in length'
26
+
27
+ validates_length_of :description,
28
+ :maximum => 255,
29
+ :message => 'must be less than %d characters in length'
30
+
31
+ validates_length_of :host,
32
+ :maximum => 255,
33
+ :allow_nil => true,
34
+ :message => 'must be less than %d characters in length'
35
+
36
+ validates_length_of :username,
37
+ :maximum => 32,
38
+ :allow_nil => true,
39
+ :message => 'must be less than %d characters in length'
40
+
41
+ validates_length_of :password,
42
+ :maximum => 40,
43
+ :allow_nil => true,
44
+ :message => 'must be less than %d characters in length'
45
+
46
+ #
47
+ #
48
+ #
49
+ def del_table( table )
50
+ switch( self ) do
51
+ ActiveRecord::Base.connection.drop_table( table.to_sym )
52
+ end
53
+ end
54
+
55
+ #
56
+ # This method switches ActiveRecord's connection to the actual
57
+ # database this database model represents, creates a table, then
58
+ # switches back to the RailsDB database.
59
+ #
60
+ # Only the first field is included in the create_table call. The
61
+ # rest are added using add_column.
62
+ #
63
+ def create_tbl( params )
64
+ switch( self ) do
65
+ options = {}
66
+ options[:id] = false if params[:add_id] == '0'
67
+ col_options = mangle_column_options( params, '1' )
68
+ ActiveRecord::Base.connection.create_table( params[:name].to_sym, options ) do |t|
69
+ t.column params[:fields]['1'][:name].to_sym, params[:fields]['1'][:type].to_sym, col_options
70
+ end
71
+ table = self.get_table( params[:name] )
72
+ table.add_fields( params ) if table
73
+ end
74
+ end
75
+
76
+ def get_table( name )
77
+ switch( self ) do
78
+ return Table.new( self, name ) if ActiveRecord::Base.connection.tables.include? name
79
+ end
80
+ nil
81
+ end
82
+
83
+ #
84
+ # This method switches ActiveRecord's connection to the actual
85
+ # database this database model represents, grabs a table list,
86
+ # then switches back to the RailsDB database.
87
+ #
88
+ def tables
89
+ tables = []
90
+ switch( self ) do
91
+ ActiveRecord::Base.connection.tables.each do |t|
92
+ tables << Table.new( self, t )
93
+ end
94
+ end
95
+ tables
96
+ end
97
+
98
+ #
99
+ # This provides just the table names, not table objects
100
+ #
101
+ def table_names
102
+ self.tables.collect { |t| t.name }
103
+ end
104
+
105
+ #
106
+ # Does this database contain a table with passed name?
107
+ #
108
+ def has_table?( name )
109
+ self.table_names.each { |t| return true if t == name }
110
+ false
111
+ end
112
+
113
+ end