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.



68
69
70
# File 'lib/namira/config.rb', line 68

def initialize
  super(DEFAULT_SETTINGS)
end

Instance Attribute Details

#async_adapterSymbol

The preferred async adapter to use. Possible Values: :active_job, :sidekiq

Returns:

  • (Symbol)

    Defaults: :active_job



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#async_queue_nameSymbol

The queue name that async requests should be added too.

Returns:

  • (Symbol)

    Defaults: :default



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#backendNamira::Backend

The backend Namira will use to send the request.

Returns:

  • (Namira::Backend)

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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end

#headersHash (readonly)

Default headers to send with each request

Returns:

  • (Hash)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/namira/config.rb', line 47

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: {},
    log_requests: true,
    async_queue_name: :default,
    async_adapter: :active_job
  }.freeze

  private_constant :DEFAULT_SETTINGS

  def initialize
    super(DEFAULT_SETTINGS)
  end
end