Module: Backup::Configuration::Helpers
- Included in:
- 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.
-
#getter_methods ⇒ Object
Returns an array of getter methods (as Array).
-
#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.
-
#setter_methods ⇒ Object
Returns an array of the setter methods (as String).
Instance Method Details
#clear_defaults! ⇒ Object
Clears all the defaults that may have been set by the user
26 27 28 29 30 |
# File 'lib/backup/configuration/helpers.rb', line 26 def clear_defaults! setter_methods.each do |method| self.send(method, nil) end end |
#getter_methods ⇒ Object
Returns an array of getter methods (as Array)
43 44 45 46 47 48 49 50 |
# File 'lib/backup/configuration/helpers.rb', line 43 def getter_methods methods.map do |method| method = method.to_s if method =~ /^\w(\w|\d|\_)+\=$/ and method != 'taguri=' method.sub('=','') end end.compact 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 |
# File 'lib/backup/configuration/helpers.rb', line 11 def load_defaults! c = self.class.name.split('::') configuration = Backup::Configuration.const_get(c[1]).const_get(c[2]) getter_methods.each do |attribute| if configuration.respond_to?(attribute) unless configuration.send(attribute).nil? self.send("#{attribute}=", configuration.send(attribute)) end end end end |
#setter_methods ⇒ Object
Returns an array of the setter methods (as String)
34 35 36 37 38 39 |
# File 'lib/backup/configuration/helpers.rb', line 34 def setter_methods methods.map do |method| method = method.to_s method if method =~ /^\w(\w|\d|\_)+\=$/ and method != 'taguri=' end.compact end |