Class: TinyClient::Configuration Abstract

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/tiny_client/configuration.rb

Overview

This class is abstract.

Provides the default client configuration Subclass and override #initialize to implement a client confiuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

You need to initialize the api #url, default #headers, and default limit.

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/tiny_client/configuration.rb', line 13

def initialize
  raise NotImplementedError
end

Instance Attribute Details

#limitInteger (readonly)

default limit used as a query param

Returns:

  • (Integer)

    the current value of limit



7
8
9
# File 'lib/tiny_client/configuration.rb', line 7

def limit
  @limit
end

#urlString (readonly)

the api root url (i.e: localhost/api/1.0)

Returns:

  • (String)

    the current value of url



7
8
9
# File 'lib/tiny_client/configuration.rb', line 7

def url
  @url
end

Instance Method Details

#connect_timeoutInteger

Returns request connection timeout in seconds.

Returns:

  • (Integer)

    request connection timeout in seconds



18
19
20
# File 'lib/tiny_client/configuration.rb', line 18

def connect_timeout
  @connect_timeout ||= 30
end

#headersHash

Returns headers default headers you want to pass along every request.

Returns:

  • (Hash)

    headers default headers you want to pass along every request



23
24
25
# File 'lib/tiny_client/configuration.rb', line 23

def headers
  @headers ||= {}
end

#requestorTinyClient::RemoteClient

Returns requestor.

Returns:



44
45
46
# File 'lib/tiny_client/configuration.rb', line 44

def requestor
  @requestor ||= TinyClient::RemoteClient.new(self)
end

#url_builderTinyClient::UrlBuilder

Returns url_builder.

Returns:



39
40
41
# File 'lib/tiny_client/configuration.rb', line 39

def url_builder
  TinyClient::UrlBuilder.url(url)
end

#url_for(*args) ⇒ String

Returns url using ‘TinyClient::UrlBuilder` to build url.

Returns:

  • (String)

    url using ‘TinyClient::UrlBuilder` to build url



33
34
35
36
# File 'lib/tiny_client/configuration.rb', line 33

def url_for(*args)
  query = args.extract_options!
  url_builder.path(*args).query(query).build
end

#verboseBoolean

Returns true if curl verbose option is set.

Returns:

  • (Boolean)

    true if curl verbose option is set



28
29
30
# File 'lib/tiny_client/configuration.rb', line 28

def verbose
  @verbose ||= false
end