Class: Refinery::Config
- Inherits:
-
Object
- Object
- Refinery::Config
- Defined in:
- lib/refinery/config.rb
Overview
Configuration class.
Class Method Summary collapse
-
.default ⇒ Object
Get a shared configuration.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get the configuration value.
-
#[]=(key, value) ⇒ Object
Set the configuration value.
-
#initialize(data = {}) ⇒ Config
constructor
Initialize the config with the given data.
-
#load_file(file) ⇒ Object
Load configuration from a YAML file.
-
#refresh ⇒ Object
Refresh the configuration from the YAML file if necessary.
Constructor Details
#initialize(data = {}) ⇒ Config
Initialize the config with the given data
15 16 17 |
# File 'lib/refinery/config.rb', line 15 def initialize(data={}) @data = data end |
Class Method Details
.default ⇒ Object
Get a shared configuration
5 6 7 8 9 10 11 12 |
# File 'lib/refinery/config.rb', line 5 def self.default @default ||= new({ 'aws' => { 'credentials' => {} }, 'processors' => {} }) end |
Instance Method Details
#[](key) ⇒ Object
Get the configuration value
20 21 22 |
# File 'lib/refinery/config.rb', line 20 def [](key) data[key.to_s] end |
#[]=(key, value) ⇒ Object
Set the configuration value
25 26 27 |
# File 'lib/refinery/config.rb', line 25 def []=(key, value) data[key.to_s] = value end |
#load_file(file) ⇒ Object
Load configuration from a YAML file
30 31 32 33 34 |
# File 'lib/refinery/config.rb', line 30 def load_file(file) @file = file @data = YAML::load_file(@file) @last_load = File.mtime(@file) end |
#refresh ⇒ Object
Refresh the configuration from the YAML file if necessary.
37 38 39 40 41 |
# File 'lib/refinery/config.rb', line 37 def refresh if File.mtime(@file) != @last_load @data = YAML::load_file(@file) end end |