2010-09-07 15:21:16 -04:00
|
|
|
module Fog
|
2011-08-31 16:52:53 -04:00
|
|
|
|
|
|
|
def self.providers
|
|
|
|
@providers ||= []
|
|
|
|
end
|
|
|
|
|
2011-10-19 16:59:17 -04:00
|
|
|
def self.providers=(new_providers)
|
|
|
|
@providers = new_providers
|
|
|
|
end
|
|
|
|
|
2010-09-07 15:21:16 -04:00
|
|
|
module Provider
|
|
|
|
|
2011-02-04 11:17:30 -05:00
|
|
|
def self.extended(base)
|
2011-10-19 16:59:17 -04:00
|
|
|
Fog.providers |= [base.to_s.split('::').last]
|
2011-02-04 11:17:30 -05:00
|
|
|
end
|
|
|
|
|
2011-09-22 20:00:48 -04:00
|
|
|
def [](service_key)
|
|
|
|
eval(@services_registry[service_key]).new
|
|
|
|
end
|
|
|
|
|
|
|
|
def service(new_service, path, constant_string)
|
2011-07-27 10:30:49 -04:00
|
|
|
Fog.services[new_service] ||= []
|
2011-09-22 17:04:24 -04:00
|
|
|
Fog.services[new_service] |= [self.to_s.split('::').last.downcase.to_sym]
|
2011-09-22 20:00:48 -04:00
|
|
|
@services_registry ||= {}
|
|
|
|
@services_registry[new_service] = [self.to_s, constant_string].join('::')
|
2011-01-07 18:09:46 -05:00
|
|
|
require File.join('fog', path)
|
2010-09-07 15:21:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def services
|
2011-09-22 20:00:48 -04:00
|
|
|
@services_registry.keys
|
2011-09-22 17:04:24 -04:00
|
|
|
end
|
|
|
|
|
2010-09-07 15:21:16 -04:00
|
|
|
end
|
|
|
|
end
|