Module: Camping::GuideBook

Defined in:
lib/guidebook.rb

Defined Under Namespace

Classes: ActiveRecordCloser

Class Method Summary collapse

Class Method Details

.setup(app, *a, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/guidebook.rb', line 31

def self.setup(app, *a, &block)
  app.use ActiveRecordCloser

  # Puts the Base Class into your apps' Models module.
  app::Models.module_eval $AR_TO_BASE

  # The defaults are all for localhosting.
  db_host   = app.options[:db_host]        ||=  'localhost'
  adapter   = app.options[:adapter]        ||=  'sqlite3'
  database  = app.options[:database]       ||=  'camping'
  pool      = app.options[:database_pool]  ||=  5

  # Establishes the database connection.
  # Because we're doing all of this in the setup method
  # The connection will take place when this gear is packed.
  app::Models::Base.establish_connection(
    :adapter => adapter,
    :database => database,
    :host => db_host,
    :pool => pool
  )
end