Class: GoApiClient::Client
- Inherits:
-
Object
- Object
- GoApiClient::Client
- Defined in:
- lib/go_api_client/client.rb
Instance Method Summary collapse
- #api(name, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/go_api_client/client.rb', line 3 def initialize(={}) = ({:uri => nil, :username => nil, :password => nil, :ssl_verify_mode => nil}).merge() @http_fetcher = GoApiClient::HttpFetcher.new() if [:uri] @base_uri = [:uri].chomp('/') else = ({:host => 'localhost', :port => 8153, :ssl => false}).merge() @base_uri = "#{[:ssl] ? 'https' : 'http'}://#{[:host]}:#{[:port]}/go" end end |
Instance Method Details
#api(name, options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/go_api_client/client.rb', line 14 def api(name, ={}) class_name = name.slice(0, 1).capitalize + name.slice(1..-1) api_class = "#{self.class.to_s.split('::').first}::Api::#{class_name}".split('::').inject(Object) { |n, c| n.const_get c } api_class.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher}.merge()) end |