Module: CouchRestAdapter::DbConfig::ClassMethods

Defined in:
lib/couch_rest_adapter/db_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config_fileObject

Returns the value of attribute config_file.



8
9
10
# File 'lib/couch_rest_adapter/db_config.rb', line 8

def config_file
  @config_file
end

Instance Method Details

#auth_info(parts) ⇒ Object



14
15
16
17
# File 'lib/couch_rest_adapter/db_config.rb', line 14

def auth_info parts
    return "" unless parts['username'].present?
    "#{parts['username']}:#{parts['password']}@"
end

#base_pathObject



19
20
21
22
# File 'lib/couch_rest_adapter/db_config.rb', line 19

def base_path
  parts = parse_config[Rails.env]
  "#{parts['protocol']}://#{auth_info parts}#{parts['host']}:#{parts['port']}"
end

#default_design_docObject



33
34
35
# File 'lib/couch_rest_adapter/db_config.rb', line 33

def default_design_doc
  parse_config[Rails.env]['design_doc']
end

#full_pathObject



24
25
26
# File 'lib/couch_rest_adapter/db_config.rb', line 24

def full_path
  "#{base_path}/#{parse_config[Rails.env]['name']}"
end

#parse_configObject



10
11
12
# File 'lib/couch_rest_adapter/db_config.rb', line 10

def parse_config
  YAML::load( ERB.new( File.read(config_file) ).result)
end