Class: Adhearsion::ActiveRecord::Plugin::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/activerecord/plugin/service.rb

Class Method Summary collapse

Class Method Details

.startObject

Start the ActiveRecord connection with the configured database



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/adhearsion/activerecord/plugin/service.rb', line 9

def start
  raise "Must supply an adapter argument to the ActiveRecord configuration" if (config.adapter.nil? || config.adapter.empty?)

  params = config.__values.select { |k,v| !v.nil? }

  require_models(*params.delete(:model_paths))
  establish_connection params

  ::ActiveRecord::Base.logger = logger

  create_call_hook_for_connection_cleanup
end

.stopObject

Stop the database connection



24
25
26
# File 'lib/adhearsion/activerecord/plugin/service.rb', line 24

def stop
  ::ActiveRecord::Base.remove_connection
end