Class: CartoDB::Init

Inherits:
Object show all
Defined in:
lib/cartodb-rb-client/cartodb/init.rb

Class Method Summary collapse

Class Method Details

.start(cartodb_settings = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cartodb-rb-client/cartodb/init.rb', line 6

def start(cartodb_settings = nil)
  if cartodb_settings.blank?
    config_path = Rails.root.join('config/cartodb_config.yml')
    cartodb_settings = YAML.load_file(config_path)[Rails.env.to_s] if File.exists?(config_path)
  end

  return if cartodb_settings.blank?

  if CartoDB.const_defined?('Settings')
    CartoDB::Settings.merge!(cartodb_settings)
  else
    CartoDB.const_set('Settings', cartodb_settings)
  end

  CartoDB.const_set('Connection', CartoDB::Client::Connection::Base.new) unless CartoDB.const_defined?('Connection')


end