Class: PXCBackup::PathResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/pxcbackup/path_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PathResolver

Returns a new instance of PathResolver.



5
6
7
8
# File 'lib/pxcbackup/path_resolver.rb', line 5

def initialize(options = {})
  @options = options
  @paths = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/pxcbackup/path_resolver.rb', line 10

def method_missing(name, *arguments)
  unless @paths[name]
    @paths[name] = @options["#{name.to_s}_path".to_sym] || `which #{name.to_s.shellescape}`.strip
    raise "cannot find path for '#{name.to_s}'" unless File.file?(@paths[name])
  end
  @paths[name]
end