Module: HttpConnectionPool::Connectable::PoolAccessors

Defined in:
lib/http_connection_pool/connectable.rb

Overview

Class-level configuration attributes. Readers walk the ancestor chain so subclasses inherit configuration without having to restate it; the writer pins the value on that class.

Instance Attribute Summary collapse

Instance Attribute Details

#base_urlObject

Raises:

  • (NotImplementedError)


66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/http_connection_pool/connectable.rb', line 66

def base_url
  # Walk superclass chain until we find a set value.
  klass = self
  while klass
    return klass.instance_variable_get(:@base_url) if
      klass.instance_variable_defined?(:@base_url) && klass.instance_variable_get(:@base_url)

    klass = klass.respond_to?(:superclass) ? klass.superclass : nil
  end

  raise NotImplementedError,
        "#{name || inspect} must set `self.base_url = <url>` before using the connection pool"
end

#pool_optionsObject



102
103
104
105
106
107
108
109
110
111
# File 'lib/http_connection_pool/connectable.rb', line 102

def pool_options
  klass = self
  while klass
    return klass.instance_variable_get(:@pool_options) if
      klass.instance_variable_defined?(:@pool_options)

    klass = klass.respond_to?(:superclass) ? klass.superclass : nil
  end
  {}
end

#pool_sizeObject



80
81
82
83
84
85
86
87
88
89
# File 'lib/http_connection_pool/connectable.rb', line 80

def pool_size
  klass = self
  while klass
    return klass.instance_variable_get(:@pool_size) if
      klass.instance_variable_defined?(:@pool_size)

    klass = klass.respond_to?(:superclass) ? klass.superclass : nil
  end
  Pool::DEFAULT_SIZE
end

#pool_timeoutObject



91
92
93
94
95
96
97
98
99
100
# File 'lib/http_connection_pool/connectable.rb', line 91

def pool_timeout
  klass = self
  while klass
    return klass.instance_variable_get(:@pool_timeout) if
      klass.instance_variable_defined?(:@pool_timeout)

    klass = klass.respond_to?(:superclass) ? klass.superclass : nil
  end
  Pool::DEFAULT_TIMEOUT
end