Module: DataShift::ThorBehavior

Includes:
Logging
Defined in:
lib/tasks/thor_behaviour.rb

Instance Method Summary collapse

Methods included from Logging

#logdir, #logdir=, #logger, #verbose

Instance Method Details

#start_connectionsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tasks/thor_behaviour.rb', line 11

def start_connections

  if File.exist?(File.expand_path('config/environment.rb'))
    begin
      require File.expand_path('config/environment.rb')
    rescue StandardError => e
      logger.error("Failed to initialise ActiveRecord : #{e.message}")
      raise ConnectionError, "Failed to initialise ActiveRecord : #{e.message}"
    end

  else
    raise PathError, 'Are you a RAILS Project ? No config/environment.rb found - cannot initialise ActiveRecord'
    # TODO: make this more robust ? e.g what about when using active record but not in Rails app, Sinatra etc
  end
end