Class: Yarrow::Configuration

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/yarrow/configuration.rb

Overview

Hash-like object containing runtime configuration values. Can be accessed indifferently via object style lookups or symbol keys.

Class Method Summary collapse

Class Method Details

.clearObject

Clears the global configuration to the empty default.



34
35
36
# File 'lib/yarrow/configuration.rb', line 34

def clear
  @@configuration = self.new
end

.instanceYarrow::Configuration

Provides access to the registered global configuration.

If no configuration is registered, returns a blank object.



18
19
20
# File 'lib/yarrow/configuration.rb', line 18

def instance
  @@configuration ||= self.new
end

.load(file) ⇒ Yarrow::Configuration

Loads a configuration object from the given YAML file.

Parameters:

  • path (String)

    to YAML file

Returns:



56
57
58
# File 'lib/yarrow/configuration.rb', line 56

def load(file)
  self.new(YAML.load_file(file))
end

.merge(config) ⇒ Object

Merges the given configuration or hash-like object with the registered global configuration.

Parameters:



45
46
47
# File 'lib/yarrow/configuration.rb', line 45

def merge(config)
  instance.deep_merge!(config)
end

.register(file) ⇒ Object

Loads and registers a global configuration object.

Parameters:

  • path (String)

    to YAML file



27
28
29
# File 'lib/yarrow/configuration.rb', line 27

def register(file)
  @@configuration = self.load(file)
end