Class: Elastictastic::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/elastictastic/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
# File 'lib/elastictastic/configuration.rb', line 8

def initialize
  @extra_middlewares = []
end

Instance Attribute Details

#adapterObject



20
21
22
# File 'lib/elastictastic/configuration.rb', line 20

def adapter
  @adapter ||= :net_http
end

#auto_refreshObject



33
34
35
# File 'lib/elastictastic/configuration.rb', line 33

def auto_refresh
  !!@auto_refresh
end

#backoff_maxObject

Returns the value of attribute backoff_max.



5
6
7
# File 'lib/elastictastic/configuration.rb', line 5

def backoff_max
  @backoff_max
end

#backoff_startObject

Returns the value of attribute backoff_start.



5
6
7
# File 'lib/elastictastic/configuration.rb', line 5

def backoff_start
  @backoff_start
end

#backoff_thresholdObject

Returns the value of attribute backoff_threshold.



5
6
7
# File 'lib/elastictastic/configuration.rb', line 5

def backoff_threshold
  @backoff_threshold
end

#connect_timeoutObject

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_sizeObject



37
38
39
# File 'lib/elastictastic/configuration.rb', line 37

def default_batch_size
  @default_batch_size ||= 100
end

#default_indexObject



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_middlewaresObject (readonly)

Returns the value of attribute extra_middlewares.



6
7
8
# File 'lib/elastictastic/configuration.rb', line 6

def extra_middlewares
  @extra_middlewares
end

#hostsObject



16
17
18
# File 'lib/elastictastic/configuration.rb', line 16

def hosts
  @hosts ||= [default_host]
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/elastictastic/configuration.rb', line 5

def logger
  @logger
end

#request_timeoutObject

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_engineObject



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

#presetsObject



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