module BatchKit::Configurable::ClassMethods
Defines the methods that are to be added as class methods to the class that includes the Configurable
module.
Public Instance Methods
config()
click to toggle source
Returns the {BatchKit::Config} object produced when loading the configuration files (or creates a new instance if no files were loaded).
# File lib/batch-kit/configurable.rb, line 42 def config @config ||= Config.new end
configure(*cfg_files)
click to toggle source
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}.
@param cfg_files [Array<String>] Path(s) to the configuration
file(s) to be loaded into a single {BatchKit::Config} object.
@option cfg_files [String] :decryption_key The master key for
decrypting any encrypted values in the configuration files.
# File lib/batch-kit/configurable.rb, line 22 def configure(*cfg_files) options = 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 = options.delete(:decryption_key) if options[:decryption_key] config.merge!(options) cfg_files.each do |cfg_file| config.load(cfg_file, options) end if defined?(BatchKit::Events) Events.publish(self, 'config.post-load', config) end config end