Class: Elastictastic::Configuration
- Inherits:
-
Object
- Object
- Elastictastic::Configuration
- Defined in:
- lib/elastictastic/configuration.rb
Instance Attribute Summary collapse
- #adapter ⇒ Object
- #auto_refresh ⇒ Object
-
#backoff_max ⇒ Object
Returns the value of attribute backoff_max.
-
#backoff_start ⇒ Object
Returns the value of attribute backoff_start.
-
#backoff_threshold ⇒ Object
Returns the value of attribute backoff_threshold.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
- #default_batch_size ⇒ Object
- #default_index ⇒ Object
-
#extra_middlewares ⇒ Object
readonly
Returns the value of attribute extra_middlewares.
- #hosts ⇒ Object
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
Instance Method Summary collapse
- #host=(host) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #json_engine ⇒ Object
- #json_engine=(json_engine) ⇒ Object
- #presets ⇒ Object
- #presets=(new_presets) ⇒ Object
- #use_middleware(*args) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 |
# File 'lib/elastictastic/configuration.rb', line 8 def initialize @extra_middlewares = [] end |
Instance Attribute Details
#adapter ⇒ Object
20 21 22 |
# File 'lib/elastictastic/configuration.rb', line 20 def adapter @adapter ||= :net_http end |
#auto_refresh ⇒ Object
33 34 35 |
# File 'lib/elastictastic/configuration.rb', line 33 def auto_refresh !!@auto_refresh end |
#backoff_max ⇒ Object
Returns the value of attribute backoff_max.
5 6 7 |
# File 'lib/elastictastic/configuration.rb', line 5 def backoff_max @backoff_max end |
#backoff_start ⇒ Object
Returns the value of attribute backoff_start.
5 6 7 |
# File 'lib/elastictastic/configuration.rb', line 5 def backoff_start @backoff_start end |
#backoff_threshold ⇒ Object
Returns the value of attribute backoff_threshold.
5 6 7 |
# File 'lib/elastictastic/configuration.rb', line 5 def backoff_threshold @backoff_threshold end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
5 6 7 |
# File 'lib/elastictastic/configuration.rb', line 5 def connect_timeout @connect_timeout end |
#default_batch_size ⇒ Object
37 38 39 |
# File 'lib/elastictastic/configuration.rb', line 37 def default_batch_size @default_batch_size ||= 100 end |
#default_index ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/elastictastic/configuration.rb', line 24 def default_index return @default_index if defined? @default_index if url_from_env && url_from_env.path =~ /^\/([^\/]+)/ @default_index = $1 else @default_index = 'default' end end |
#extra_middlewares ⇒ Object (readonly)
Returns the value of attribute extra_middlewares.
6 7 8 |
# File 'lib/elastictastic/configuration.rb', line 6 def extra_middlewares @extra_middlewares end |
#hosts ⇒ Object
16 17 18 |
# File 'lib/elastictastic/configuration.rb', line 16 def hosts @hosts ||= [default_host] end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/elastictastic/configuration.rb', line 5 def logger @logger end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
5 6 7 |
# File 'lib/elastictastic/configuration.rb', line 5 def request_timeout @request_timeout end |
Instance Method Details
#host=(host) ⇒ Object
12 13 14 |
# File 'lib/elastictastic/configuration.rb', line 12 def host=(host) @hosts = [host] end |
#json_engine ⇒ Object
49 50 51 |
# File 'lib/elastictastic/configuration.rb', line 49 def json_engine @json_engine || MultiJson.engine end |
#json_engine=(json_engine) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/elastictastic/configuration.rb', line 41 def json_engine=(json_engine) original_engine = MultiJson.engine MultiJson.engine = json_engine @json_engine = MultiJson.engine ensure MultiJson.engine = original_engine end |
#presets ⇒ Object
57 58 59 |
# File 'lib/elastictastic/configuration.rb', line 57 def presets @presets ||= ActiveSupport::HashWithIndifferentAccess.new end |
#presets=(new_presets) ⇒ Object
61 62 63 |
# File 'lib/elastictastic/configuration.rb', line 61 def presets=(new_presets) presets.merge!(new_presets) end |
#use_middleware(*args) ⇒ Object
53 54 55 |
# File 'lib/elastictastic/configuration.rb', line 53 def use_middleware(*args) @extra_middlewares << args end |