Module: BatchKit::Configurable::ClassMethods
- Defined in:
- lib/batch-kit/configurable.rb
Overview
Defines the methods that are to be added as class methods to the class that includes the Configurable module.
Instance Method Summary collapse
-
#config ⇒ Object
Returns the BatchKit::Config object produced when loading the configuration files (or creates a new instance if no files were loaded).
-
#configure(*cfg_files) ⇒ Object
Configure the class by loading the configuration files specifed.
Instance Method Details
#config ⇒ Object
Returns the BatchKit::Config object produced when loading the configuration files (or creates a new instance if no files were loaded).
42 43 44 |
# File 'lib/batch-kit/configurable.rb', line 42 def config @config ||= Config.new end |
#configure(*cfg_files) ⇒ Object
Configure the class by loading the configuration files specifed. If the last argument passed to this method is a Hash, it is treated an options hash, which is passed into BatchKit::Config.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/batch-kit/configurable.rb', line 22 def configure(*cfg_files) = cfg_files.last.is_a?(Hash) ? cfg_files.pop.clone : {} if defined?(BatchKit::Events) Events.publish(self, 'config.pre-load', config, cfg_files) end config.decryption_key = .delete(:decryption_key) if [:decryption_key] config.merge!() cfg_files.each do |cfg_file| config.load(cfg_file, ) end if defined?(BatchKit::Events) Events.publish(self, 'config.post-load', config) end config end |