Class: Dm3::Api::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/dm3/api/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, service_url) ⇒ Connection

Returns a new instance of Connection.



4
5
6
7
# File 'lib/dm3/api/connection.rb', line 4

def initialize(token, service_url)
  @token = token
  @service_url = service_url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/dm3/api/connection.rb', line 9

def method_missing(method_name, *args, &block)
  request_class = request_class_for_method(method_name)
  if request_class
    request_class.new(self, args.extract_options!).perform
  else
    super
  end
end

Instance Attribute Details

#service_urlObject (readonly)

Returns the value of attribute service_url.



2
3
4
# File 'lib/dm3/api/connection.rb', line 2

def service_url
  @service_url
end

#tokenObject (readonly)

Returns the value of attribute token.



2
3
4
# File 'lib/dm3/api/connection.rb', line 2

def token
  @token
end

Instance Method Details

#use_ssl?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dm3/api/connection.rb', line 18

def use_ssl?
  service_uri.scheme == 'https'
end