Class: IndexTanked::InstanceCompanion
- Inherits:
-
Object
- Object
- IndexTanked::InstanceCompanion
show all
- Defined in:
- lib/index-tanked/instance_companion.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of InstanceCompanion.
4
5
6
7
|
# File 'lib/index-tanked/instance_companion.rb', line 4
def initialize(companion)
@companion = companion
@index_tanked = companion.class.index_tanked
end
|
Instance Method Details
#api_client ⇒ Object
44
45
46
|
# File 'lib/index-tanked/instance_companion.rb', line 44
def api_client
@index_tanked.api_client
end
|
#data ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/index-tanked/instance_companion.rb', line 9
def data
field_data = {}
other_data = {}
text_values = @index_tanked.texts.map { |method| @index_tanked.get_value_from(@companion, method) }
@index_tanked.fields.each do |(field, method, options)|
value = @index_tanked.get_value_from(@companion, method)
unless value.nil?
field_data[field] = value
text_values << (options.has_key?(:text) ? @index_tanked.get_value_from(@companion, options[:text]) : field_data[field])
end
end
field_data.merge!(:text => text_values.compact.uniq.join(" "))
variables = @index_tanked.variables.inject({}) do |variables, (variable, method)|
variables[variable] = @index_tanked.get_value_from(@companion, method)
variables
end
other_data[:variables] = variables unless variables.empty?
[field_data, other_data]
end
|
#doc_id ⇒ Object
40
41
42
|
# File 'lib/index-tanked/instance_companion.rb', line 40
def doc_id
@index_tanked.get_value_from(@companion, @index_tanked.doc_id_value)
end
|
#document_for_batch_addition ⇒ Object
35
36
37
38
|
# File 'lib/index-tanked/instance_companion.rb', line 35
def document_for_batch_addition
fields, document = *data
document.merge!(:docid => doc_id, :fields => fields)
end
|
#index ⇒ Object
48
49
50
|
# File 'lib/index-tanked/instance_companion.rb', line 48
def index
@index_tanked.index
end
|