Module: Eson::QueryPlugin
- Defined in:
- lib/eson/modules/query_plugin.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/eson/modules/query_plugin.rb', line 20
def method_missing(sym, *args, &block)
if query.query.respond_to?(sym)
query.query.send(sym, *args, &block)
else
super
end
end
|
Class Method Details
.plugin_for(protocol) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/eson/modules/query_plugin.rb', line 28
def self.plugin_for(protocol)
[protocol::Search,
protocol::Count,
protocol::DeleteByQuery,
protocol::Percolate,
protocol::Explain,
protocol::Validate]
end
|
Instance Method Details
#call(*args) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/eson/modules/query_plugin.rb', line 12
def call(*args)
if query.respond_to?(:to_query_hash)
self.parameters = query.to_query_hash
end
super(*args)
end
|
#handle_block(&block) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/eson/modules/query_plugin.rb', line 37
def handle_block(&block)
if (block.arity == 0) || (block.arity == -1)
query(&block)
else
super
end
end
|
#query ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'lib/eson/modules/query_plugin.rb', line 3
def query
if block_given?
@query ||= Eson::Search::BaseQuery.new
@query.instance_exec(@query, &Proc.new)
end
@query
end
|