Class: Namira::Config

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/namira/config.rb

Overview

Namira configuration

Namira.configure do |config|
  config.user_agent = "MyCoolApp"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



57
58
59
# File 'lib/namira/config.rb', line 57

def initialize
  super(DEFAULT_SETTINGS)
end

Instance Attribute Details

#backendNamira::Backend

The backend Namira will use to send the request.

Returns:

  • (Namira::Backend)

    This returns a Class and not an instance. Defaults: Backend



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/namira/config.rb', line 38

class Config < OpenStruct
  ##
  # The
  # attr_accessor :max_redirect
  # attr_accessor :timeout
  # attr_accessor :backend
  # attr_accessor :user_agent

  DEFAULT_SETTINGS = {
    max_redirect: 3,
    timeout:      5.0,
    backend:      nil,
    user_agent:   "Namira/#{Namira::VERSION}",
    headers:      OpenStruct.new,
    log_requests: true
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#headersOpenStruct (readonly)

Default headers to send with each request

Returns:

  • (OpenStruct)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/namira/config.rb', line 38

class Config < OpenStruct
  ##
  # The
  # attr_accessor :max_redirect
  # attr_accessor :timeout
  # attr_accessor :backend
  # attr_accessor :user_agent

  DEFAULT_SETTINGS = {
    max_redirect: 3,
    timeout:      5.0,
    backend:      nil,
    user_agent:   "Namira/#{Namira::VERSION}",
    headers:      OpenStruct.new,
    log_requests: true
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#log_requestsBool

Log requests using puts or Rails.logger.debug if it’s defined

Returns:

  • (Bool)

    Defaults: true



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/namira/config.rb', line 38

class Config < OpenStruct
  ##
  # The
  # attr_accessor :max_redirect
  # attr_accessor :timeout
  # attr_accessor :backend
  # attr_accessor :user_agent

  DEFAULT_SETTINGS = {
    max_redirect: 3,
    timeout:      5.0,
    backend:      nil,
    user_agent:   "Namira/#{Namira::VERSION}",
    headers:      OpenStruct.new,
    log_requests: true
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#max_redirectInteger

The maximum number of redirects to follow before throwing a Errors::RedirectError

Returns:

  • (Integer)

    Defaults: 3



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/namira/config.rb', line 38

class Config < OpenStruct
  ##
  # The
  # attr_accessor :max_redirect
  # attr_accessor :timeout
  # attr_accessor :backend
  # attr_accessor :user_agent

  DEFAULT_SETTINGS = {
    max_redirect: 3,
    timeout:      5.0,
    backend:      nil,
    user_agent:   "Namira/#{Namira::VERSION}",
    headers:      OpenStruct.new,
    log_requests: true
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#timeoutFloat

The max length of time (in seconds) Namira will wait before canceling the request and throwing a Errors::TimeoutError

Returns:

  • (Float)

    Defaults: 5.0



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/namira/config.rb', line 38

class Config < OpenStruct
  ##
  # The
  # attr_accessor :max_redirect
  # attr_accessor :timeout
  # attr_accessor :backend
  # attr_accessor :user_agent

  DEFAULT_SETTINGS = {
    max_redirect: 3,
    timeout:      5.0,
    backend:      nil,
    user_agent:   "Namira/#{Namira::VERSION}",
    headers:      OpenStruct.new,
    log_requests: true
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#user_agentString

The string to send for the “User-Agent” header. The value set here will be overriden if a user agent is specified on the request itself.

Returns:

  • (String)

    Defaults: Namira/1.0



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/namira/config.rb', line 38

class Config < OpenStruct
  ##
  # The
  # attr_accessor :max_redirect
  # attr_accessor :timeout
  # attr_accessor :backend
  # attr_accessor :user_agent

  DEFAULT_SETTINGS = {
    max_redirect: 3,
    timeout:      5.0,
    backend:      nil,
    user_agent:   "Namira/#{Namira::VERSION}",
    headers:      OpenStruct.new,
    log_requests: true
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end