Class: Almicube::Config

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/almicube/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#connection(env = :default) ⇒ Object

Returns the value of attribute connection.

Raises:

  • (ArgumentError)


6
7
8
# File 'lib/almicube/config.rb', line 6

def connection
  @connection
end

#key_formatObject

Returns the value of attribute key_format.



6
7
8
# File 'lib/almicube/config.rb', line 6

def key_format
  @key_format
end

Class Method Details

.configObject



17
18
19
20
21
22
# File 'lib/almicube/config.rb', line 17

def config
  if @instance.nil? && File.exists?(filepath)
    @instance = self.new YAML.load_file(filepath)
  end
  @instance ||= self.new {}
end

.filepathObject



13
14
15
# File 'lib/almicube/config.rb', line 13

def filepath
  @filepath ||= File.join(root.to_s, "config", "almicube.yml")
end

.resetObject



24
25
26
# File 'lib/almicube/config.rb', line 24

def reset
  @instance = nil
end

.rootObject



9
10
11
# File 'lib/almicube/config.rb', line 9

def root
  Rails.root if defined? Rails
end