Method: Days::Config#initialize

Defined in:
lib/days/config.rb

#initialize(hash_or_file = {}, section = nil) ⇒ Config

Returns a new instance of Config.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/days/config.rb', line 18

def initialize(hash_or_file = {}, section = nil)
  super
  if section.nil?
    if String === hash_or_file
      self[:root] = File.dirname(hash_or_file)
    else
      self[:root] = "."
    end

    self['database'].tap do |hash|
      next unless hash
      if hash['adapter'] == 'sqlite3' && /^\// !~ hash['database']
        hash['database'] = File.join(self.root, hash['database'])
      end
    end
  end
end