Class: IndexTanked::ClassCompanion
- Inherits:
-
Object
- Object
- IndexTanked::ClassCompanion
show all
- Defined in:
- lib/index-tanked/class_companion.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ClassCompanion.
Instance Attribute Details
#doc_id_value ⇒ Object
Returns the value of attribute doc_id_value.
3
4
5
|
# File 'lib/index-tanked/class_companion.rb', line 3
def doc_id_value
@doc_id_value
end
|
#fields ⇒ Object
Returns the value of attribute fields.
3
4
5
|
# File 'lib/index-tanked/class_companion.rb', line 3
def fields
@fields
end
|
#index_name ⇒ Object
Returns the value of attribute index_name.
3
4
5
|
# File 'lib/index-tanked/class_companion.rb', line 3
def index_name
@index_name
end
|
#index_tank_url ⇒ Object
Returns the value of attribute index_tank_url.
3
4
5
|
# File 'lib/index-tanked/class_companion.rb', line 3
def index_tank_url
@index_tank_url
end
|
#texts ⇒ Object
Returns the value of attribute texts.
3
4
5
|
# File 'lib/index-tanked/class_companion.rb', line 3
def texts
@texts
end
|
#variables ⇒ Object
Returns the value of attribute variables.
3
4
5
|
# File 'lib/index-tanked/class_companion.rb', line 3
def variables
@variables
end
|
Instance Method Details
#add_fields_to_query(query, options = {}) ⇒ Object
53
54
55
56
|
# File 'lib/index-tanked/class_companion.rb', line 53
def add_fields_to_query(query, options={})
return nil if query.blank?
[query, options[:fields] && options[:fields].to_a.map {|pair| pair.join(':')}.join(' ')].compact.join(" ").strip
end
|
#api_client ⇒ Object
37
38
39
40
|
# File 'lib/index-tanked/class_companion.rb', line 37
def api_client
return nil if @index_tank_url.nil?
@api_client ||= (IndexTanked::IndexTank::Client.new @index_tank_url)
end
|
#doc_id(method) ⇒ Object
15
16
17
|
# File 'lib/index-tanked/class_companion.rb', line 15
def doc_id(method)
@doc_id_value = method
end
|
#field(field_name, method = field_name, options = {}) ⇒ Object
19
20
21
22
|
# File 'lib/index-tanked/class_companion.rb', line 19
def field(field_name, method=field_name, options={})
method, options = field_name, method if method.is_a? Hash
@fields << [field_name, method, options]
end
|
#get_value_from(instance, method) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/index-tanked/class_companion.rb', line 42
def get_value_from(instance, method)
case method
when Symbol
instance.send method
when Proc
method.call(instance)
else
method
end
end
|
#index ⇒ Object
32
33
34
35
|
# File 'lib/index-tanked/class_companion.rb', line 32
def index
return nil if @index_name.nil? || api_client.nil?
api_client.indexes @index_name
end
|
#text(method) ⇒ Object
24
25
26
|
# File 'lib/index-tanked/class_companion.rb', line 24
def text(method)
@texts << method
end
|
#var(variable, method) ⇒ Object
28
29
30
|
# File 'lib/index-tanked/class_companion.rb', line 28
def var(variable, method)
@variables << [variable, method]
end
|