Module: Backup::Configuration::Helpers
- Included in:
- Backup::Checksum::Base, Backup::Compressor::Base, Base, Database::Base, Encryptor::Base, Notifier::Base, Storage::Base, Syncer::Base
- Defined in:
- lib/backup/configuration/helpers.rb
Instance Method Summary collapse
-
#clear_defaults! ⇒ Object
Clears all the defaults that may have been set by the user.
-
#load_defaults! ⇒ Object
Finds all the object’s getter methods and checks the global configuration for these methods, if they respond then they will assign the object’s attribute(s) to that particular global configuration’s attribute.
Instance Method Details
#clear_defaults! ⇒ Object
Clears all the defaults that may have been set by the user
27 28 29 30 31 |
# File 'lib/backup/configuration/helpers.rb', line 27 def clear_defaults! setter_methods.each do |method| self.send(method, nil) end end |
#load_defaults! ⇒ Object
Finds all the object’s getter methods and checks the global configuration for these methods, if they respond then they will assign the object’s attribute(s) to that particular global configuration’s attribute
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/backup/configuration/helpers.rb', line 11 def load_defaults! module_names = self.class.name.split('::')[1..-1] configuration = Backup::Configuration module_names.each do |module_name| configuration = configuration.const_get(module_name) end getter_methods.each do |attribute| if configuration.respond_to?(attribute) self.send("#{attribute}=", configuration.send(attribute)) end end end |