Module: Unleashed::Configurable

Included in:
Unleashed, Client
Defined in:
lib/unleashed/configurable.rb

Overview

Configuration options for Client, defaulting to values in Default.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_domainObject

Returns the value of attribute api_domain.



4
5
6
# File 'lib/unleashed/configurable.rb', line 4

def api_domain
  @api_domain
end

#api_idObject

Returns the value of attribute api_id.



4
5
6
# File 'lib/unleashed/configurable.rb', line 4

def api_id
  @api_id
end

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/unleashed/configurable.rb', line 4

def api_key
  @api_key
end

#client_type_headerObject

Returns the value of attribute client_type_header.



4
5
6
# File 'lib/unleashed/configurable.rb', line 4

def client_type_header
  @client_type_header
end

#errors_formatObject

Returns the value of attribute errors_format.



4
5
6
# File 'lib/unleashed/configurable.rb', line 4

def errors_format
  @errors_format
end

Class Method Details

.keysArray

List of configurable keys for Unleashed::Client.

Returns:

  • (Array)

    of option keys



11
12
13
14
15
16
17
18
19
# File 'lib/unleashed/configurable.rb', line 11

def keys
  @keys ||= [
    :api_domain,
    :api_id,
    :api_key,
    :client_type_header,
    :errors_format
  ]
end

Instance Method Details

#api_endpointString

API endpoint to be used by Unleashed::Client. Built from #api_domain

Returns:

  • (String)


37
38
39
# File 'lib/unleashed/configurable.rb', line 37

def api_endpoint
  "https://#{@api_domain}/"
end

#reset!Object Also known as: setup

Reset configuration options to default values.



23
24
25
26
27
28
29
# File 'lib/unleashed/configurable.rb', line 23

def reset!
  Unleashed::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Unleashed::Default.options[key])
  end

  self
end