Module: Treat::Config::Importable
- Included in:
- Treat::Config
- Defined in:
- lib/treat/config/importable.rb
Overview
Mixin that is extended by Treat::Config in order to provide a single point of access method to trigger the import.
Class Method Summary collapse
-
.extended(base) ⇒ Object
Store all the configuration in self.config.
Instance Method Summary collapse
-
#import! ⇒ Object
Main function; loads all configuration options.
Class Method Details
.extended(base) ⇒ Object
Store all the configuration in self.config
10 11 12 |
# File 'lib/treat/config/importable.rb', line 10 def self.extended(base) class << base; attr_accessor :config; end end |
Instance Method Details
#import! ⇒ Object
Main function; loads all configuration options.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/treat/config/importable.rb', line 15 def import! config, c = {}, Treat::Config::Configurable definition = :define_singleton_method Treat::Config.constants.each do |const| next if const.to_s.downcase.is_mixin? klass = Treat::Config.const_get(const) klass.class_eval { extend c }.configure! name = const.to_s.downcase.intern config[name] = klass.config Treat.send(definition, name) do Treat::Config.config[name] end end self.config = config.to_struct end |