Class: RbRotate::DirectoryConfiguration
- Defined in:
- lib/rb.rotate/configuration.rb
Overview
Directory configuration.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Returns some item.
-
#configuration ⇒ Object
Returns configuration file setting.
-
#data ⇒ Object
Returns configuration data.
-
#handle_ihneritance! ⇒ Object
Handles configuration inheritance.
-
#initialize(directory) ⇒ DirectoryConfiguration
constructor
Constructor.
-
#method_missing(name) ⇒ Object
Handles method calls.
Constructor Details
#initialize(directory) ⇒ DirectoryConfiguration
Constructor.
Expects file path and directory section specification as symbol.
33 34 35 36 |
# File 'lib/rb.rotate/configuration.rb', line 33 def initialize(directory) # TODO: this should handle configuration inheritance @directory = directory end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
Handles method calls.
88 89 90 |
# File 'lib/rb.rotate/configuration.rb', line 88 def method_missing(name) self[name] end |
Instance Method Details
#[](name) ⇒ Object
Returns some item.
80 81 82 |
# File 'lib/rb.rotate/configuration.rb', line 80 def [](name) self.data[name] end |
#configuration ⇒ Object
Returns configuration file setting.
42 43 44 |
# File 'lib/rb.rotate/configuration.rb', line 42 def configuration Configuration::get end |
#data ⇒ Object
Returns configuration data.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rb.rotate/configuration.rb', line 50 def data if @data.nil? data = self.configuration[:dirs][@directory] @data = { } # Converts strings to symbols data.each_pair do |key, value| @data[key.to_sym] = value end self.handle_inheritance! end return @data end |
#handle_ihneritance! ⇒ Object
Handles configuration inheritance.
70 71 72 73 74 |
# File 'lib/rb.rotate/configuration.rb', line 70 def handle_ihneritance! if @data.include? :parent @data.merge! self.class::new(@data[:parent]).data end end |