Class: Adhearsion::Mongoid::Plugin::Service

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

Class Method Summary collapse

Class Method Details

.startObject

Load the mongoid preferences, models and initiate logger


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adhearsion/mongoid/plugin/service.rb', line 9

def start
  params = config.to_hash.select { |k,v| !v.nil? }
  
  mongoid_config_path = fullpath *params.delete(:config_path)
  
  environment = ENV['AHN_ENV']
  environment ||= ENV['RACK_ENV']
  environment ||= ENV['RAILS_ENV']
  environment ||= 'development'
  
  logger.info "Loading Mongoid configuration ('#{environment}')"
  
  ::Mongoid.load!(mongoid_config_path, environment)
  
  logger.info "Loading Mongoid models"
  require_models(*params.delete(:models_paths))

  logger.info "Loading Mongoid logger"
  ::Mongoid.logger = logger
  ::Moped.logger = logger
  
  logger.info "Mongoid successfully configured"
end

.stopObject

stop service (unused)


35
36
# File 'lib/adhearsion/mongoid/plugin/service.rb', line 35

def stop
end