Class: Backup::Finder
- Inherits:
-
Object
- Object
- Backup::Finder
- Defined in:
- lib/backup/finder.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#trigger ⇒ Object
Returns the value of attribute trigger.
Instance Method Summary collapse
-
#find ⇒ Object
Tries to find and load the configuration file and return the proper backup model configuration (specified by the ‘trigger’).
-
#initialize(trigger, config) ⇒ Finder
constructor
Initializes a new Backup::Finder object and stores the path to the configuration file.
Constructor Details
#initialize(trigger, config) ⇒ Finder
Initializes a new Backup::Finder object and stores the path to the configuration file
10 11 12 13 |
# File 'lib/backup/finder.rb', line 10 def initialize(trigger, config) @trigger = trigger.to_sym @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/backup/finder.rb', line 5 def config @config end |
#trigger ⇒ Object
Returns the value of attribute trigger.
5 6 7 |
# File 'lib/backup/finder.rb', line 5 def trigger @trigger end |
Instance Method Details
#find ⇒ Object
Tries to find and load the configuration file and return the proper backup model configuration (specified by the ‘trigger’)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/backup/finder.rb', line 18 def find unless File.exist?(config) puts "Could not find a configuration file in '#{config}'."; exit end ## # Loads the backup configuration file instance_eval(File.read(config)) ## # Iterates through all the instantiated backup models and returns # the one that matches the specified 'trigger' Backup::Model.all.each do |model| if model.trigger.eql?(trigger) return Backup::Model.current = model end end puts "Could not find trigger '#{trigger}' in '#{config}'."; exit end |