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.
-
.load_defaults ⇒ Yarrow::Configuration
Yarrow is distributed with a ‘defaults.yml` which provides minimum boostrap configuration and default settings for various internal classes.
-
.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 instance.
-
.register_defaults ⇒ Object
Loads and registers a global configuration instance with library-provided defaults.
Class Method Details
.clear ⇒ Object
Clears the global configuration to the empty default.
43 44 45 |
# File 'lib/yarrow/configuration.rb', line 43 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.
15 16 17 |
# File 'lib/yarrow/configuration.rb', line 15 def instance @@configuration ||= self.new end |
.load(file) ⇒ Yarrow::Configuration
Loads a configuration object from the given YAML file.
64 65 66 |
# File 'lib/yarrow/configuration.rb', line 64 def load(file) self.new(YAML.load_file(file)) end |
.load_defaults ⇒ Yarrow::Configuration
Yarrow is distributed with a ‘defaults.yml` which provides minimum boostrap configuration and default settings for various internal classes. Use this method to automatically load these defaults.
74 75 76 |
# File 'lib/yarrow/configuration.rb', line 74 def load_defaults load(File.join(File.dirname(__FILE__), 'defaults.yml')) end |
.merge(config) ⇒ Object
Merges the given configuration or hash-like object with the registered global configuration.
53 54 55 |
# File 'lib/yarrow/configuration.rb', line 53 def merge(config) instance.deep_merge!(config) end |
.register(file) ⇒ Object
Loads and registers a global configuration instance.
This will reset any previously initialized configuration.
26 27 28 |
# File 'lib/yarrow/configuration.rb', line 26 def register(file) @@configuration = load(file) end |
.register_defaults ⇒ Object
Loads and registers a global configuration instance with library-provided defaults.
This will reset any previously initialized configuration.
36 37 38 |
# File 'lib/yarrow/configuration.rb', line 36 def register_defaults @@configuration = load_defaults end |