Class: Saseo::Models::Base

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/saseo/models/base.rb

Direct Known Subclasses

Source::Base, Version

Class Method Summary collapse

Class Method Details

.database_configObject



18
19
20
# File 'lib/saseo/models/base.rb', line 18

def database_config
  database_config_url || database_config_from_file
end

.database_config_from_fileObject



22
23
24
25
26
27
28
# File 'lib/saseo/models/base.rb', line 22

def database_config_from_file
  begin
    database_config_from_relative_path
  rescue
    database_config_from_load_path
  end
end

.database_config_from_load_pathObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/saseo/models/base.rb', line 34

def database_config_from_load_path
  config = nil
  config_path = database_config_path
  $:.each do |load_path|
    begin
      config = YAML::load(File.open(File.expand_path File.join(load_path, config_path)))[Saseo.config.env]
      break
    rescue
    end
  end
  config
end

.database_config_from_relative_pathObject



30
31
32
# File 'lib/saseo/models/base.rb', line 30

def database_config_from_relative_path
  YAML::load(File.open(File.expand_path(database_config_path)))[Saseo.config.env]
end

.database_config_pathObject



10
11
12
# File 'lib/saseo/models/base.rb', line 10

def database_config_path
  Saseo.config.database_config_path
end

.database_config_urlObject



14
15
16
# File 'lib/saseo/models/base.rb', line 14

def database_config_url
  Saseo.config.database_url
end