Module: Offshore::Snapshot

Extended by:
Snapshot
Included in:
Snapshot
Defined in:
lib/offshore/server/snapshot.rb,
lib/offshore/server/snapshot.rb

Defined Under Namespace

Modules: Template

Instance Method Summary collapse

Instance Method Details

#configObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/offshore/server/snapshot.rb', line 9

def config
  return @config if @config
  
  raise "Only supported in Rails for now" unless defined?(Rails)
  
  yml = Rails.root.join("config", "database.yml")
  hash = YAML.load(ERB.new(File.read(yml)).result)['test']

  @config = {}
  ['username', 'password', 'host', 'port', 'database', 'collation', 'charset'].each do |key|
    if hash['master'] && hash['master'].has_key?(key)
      @config[key] = hash['master'][key]
    else
      @config[key] = hash[key]
    end
  end
  
  @config
end