Class: Bookfile::World
- Defined in:
- lib/bookfile/database/database.rb
Overview
change to WorldDatabase or DatabaseWorld - why, why not???
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(db_config) ⇒ World
constructor
check - if it works by default (no initialze specfied).
-
#prepare ⇒ Object
change to require - why, why not??.
-
#setup ⇒ Object
use connect/prepare - why, why not??.
Constructor Details
#initialize(db_config) ⇒ World
check - if it works by default (no initialze specfied)
14 15 16 |
# File 'lib/bookfile/database/database.rb', line 14 def initialize( db_config ) ## check - if it works by default (no initialze specfied) super end |
Instance Method Details
#connect ⇒ Object
41 42 43 44 45 |
# File 'lib/bookfile/database/database.rb', line 41 def connect print " connecting..." ActiveRecord::Base.establish_connection( @db_config ) puts "OK" end |
#prepare ⇒ Object
change to require - why, why not??
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bookfile/database/database.rb', line 18 def prepare ## change to require - why, why not?? puts "setup world: #{@db_config.inspect}" res = require 'worlddb/models' if res puts " include WorldDb::Models" ### check/fix: include as globals/top-level!!! how? possible??? Builder.send :include, WorldDb::Models PageCtx.send :include, WorldDb::Models HybookHelper.send :include, WorldDb::Models ## constants not accesible (include in module too) ## BookCtx.send :include, WorldDb::Models -- needed for Book context too?? why, why not?? ## also add to xxxx ??? ## (possible to include as globals ???? how - Object.send :include ???) or ## Module.send :include ?? else ## find a better check - check for constants defined??? if not define??? ## or use constant_missing handler??? puts " assume WorldDb::Models already included ??" end end |
#setup ⇒ Object
use connect/prepare - why, why not??
47 48 49 50 |
# File 'lib/bookfile/database/database.rb', line 47 def setup ## use connect/prepare - why, why not?? prepare # step 1: prepare - require and include models connect # step 2: connect end |