Class: Tairu::Configuration
- Inherits:
-
Object
- Object
- Tairu::Configuration
- Defined in:
- lib/tairu/configuration.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#layers ⇒ Object
Returns the value of attribute layers.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(layers, cache, name = nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(layers, cache, name = nil) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 |
# File 'lib/tairu/configuration.rb', line 7 def initialize(layers, cache, name = nil) @layers = layers @cache = cache @name = name end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
5 6 7 |
# File 'lib/tairu/configuration.rb', line 5 def cache @cache end |
#layers ⇒ Object
Returns the value of attribute layers.
5 6 7 |
# File 'lib/tairu/configuration.rb', line 5 def layers @layers end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/tairu/configuration.rb', line 5 def name @name end |
Class Method Details
.config_from_file(file) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tairu/configuration.rb', line 13 def self.config_from_file(file) file = File.(file) if File.exists?(file) data = YAML.load_file(file) else raise 'Configuration file not found at specified location.' end name = data['name'] if data['name'] if data['layers'] layers = data['layers'] else raise 'Layers must be specified.' end if data['cache'] && data['cache']['type'] cache_type = data['cache']['type'] = data['cache']['options'] ? data['cache']['options'] : {} cache = start_cache(cache_type, ) end cache = Tairu::Cache::Memory.new if cache.nil? config = Configuration.new(layers, cache, name) config end |