lib/g5k.rb in cryx-g5k-0.2.6 vs lib/g5k.rb in cryx-g5k-0.2.7
- old
+ new
@@ -1,7 +1,23 @@
# Subdirs are not automatically loaded. Users must explicitly require them.
module G5K
+ class Api
+ class << self
+ # must be a hash of RestClient resources
+ attr_accessor :registered_apis
+ end
+
+ def self.select(api_name, api_version = nil, api_uri = nil)
+ if (registered_apis && api = (registered_apis[api_name] || registered_apis[api_name.to_s] || registered_apis[api_name.to_sym]))
+ api = api["/#{api_version}"] if api_version
+ api = api[api_uri] if api_uri
+ api
+ else
+ raise ArgumentError, "The API #{api_name} is not available."
+ end
+ end
+ end
end
unless [].respond_to?(:group_by) || [].respond_to?(:index_by)
require File.dirname(__FILE__)+"/g5k/enumerable_extensions"
end
\ No newline at end of file