Class: Yarrow::Configuration
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Yarrow::Configuration
- 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
-
.clear ⇒ Object
Clears the global configuration to the empty default.
-
.instance ⇒ Yarrow::Configuration
Provides access to the registered global configuration.
-
.load(file) ⇒ Yarrow::Configuration
Loads a configuration object from the given YAML file.
-
.merge(config) ⇒ Object
Merges the given configuration or hash-like object with the registered global configuration.
-
.register(file) ⇒ Object
Loads and registers a global configuration object.
Class Method Details
.clear ⇒ Object
Clears the global configuration to the empty default.
34 35 36 |
# File 'lib/yarrow/configuration.rb', line 34 def clear @@configuration = self.new end |
.instance ⇒ Yarrow::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.
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.
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.
27 28 29 |
# File 'lib/yarrow/configuration.rb', line 27 def register(file) @@configuration = self.load(file) end |