Class: Stic::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/stic/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



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

def initialize(options = {})
  @options = options
  @files   = []
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



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

def files
  @files
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

.load(file) ⇒ Object



21
22
23
# File 'lib/stic/config.rb', line 21

def load(file)
  new.tap{|c| c.load file }
end

Instance Method Details

#load(file) ⇒ Object



14
15
16
17
18
# File 'lib/stic/config.rb', line 14

def load(file)
  data = ::YAML.load(file.read) if file.exist?
  options.deep_merge(data) if data.is_a?(Hash)
  files << file
end