Class: EasyConfig::Configuration
- Inherits:
-
Object
- Object
- EasyConfig::Configuration
show all
- Defined in:
- lib/easy_config/configuration.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
4
5
6
|
# File 'lib/easy_config/configuration.rb', line 4
def initialize(config)
create_methods(config)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
15
16
17
|
# File 'lib/easy_config/configuration.rb', line 15
def method_missing(name, *args)
nil
end
|
Instance Method Details
#create_methods(config) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/easy_config/configuration.rb', line 8
def create_methods(config)
config.each do |key, value|
value = OpenStruct.new(value) if value.is_a?(Hash)
define_singleton_method(key.to_sym) { value }
end
end
|
#define_singleton_method(name, &block) ⇒ Object
20
21
22
23
|
# File 'lib/easy_config/configuration.rb', line 20
def define_singleton_method(name, &block)
singleton = class << self; self end
singleton.send(:define_method, name, &block)
end
|