Class: Confy::Backend::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/confy/backend/base.rb

Class Method Summary collapse

Class Method Details

.extensionsObject



13
14
15
# File 'lib/confy/backend/base.rb', line 13

def self.extensions
  @extensions ||= Set.new
end

.which(path) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/confy/backend/base.rb', line 4

def self.which(path)
  extension = extensions.dup.detect{|e,klass| e.to_s == File.extname(path)[1..-1] }
  if extension
    Backend.const_get(extension.pop)
  else
    raise Confy::UnsupportedFileExtensionError, "No backend available for #{path}."
  end
end