Class: Flex::Template::Search
- Inherits:
-
Flex::Template
- Object
- Flex::Template
- Flex::Template::Search
- Defined in:
- lib/flex/template/search.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Flex::Template
Attributes included from Common
#data, #name, #partials, #tags
Instance Method Summary collapse
-
#initialize(data, vars = nil) ⇒ Search
constructor
A new instance of Search.
- #to_a(*vars) ⇒ Object
- #to_msearch(*vars) ⇒ Object
Methods inherited from Flex::Template
#render, #to_source, variables
Methods included from Common
Methods included from Logger
Constructor Details
#initialize(data, vars = nil) ⇒ Search
Returns a new instance of Search.
5 6 7 |
# File 'lib/flex/template/search.rb', line 5 def initialize(data, vars=nil) super('GET', '/<<index>>/<<type>>/_search', data, vars) end |
Instance Method Details
#to_a(*vars) ⇒ Object
9 10 11 12 13 |
# File 'lib/flex/template/search.rb', line 9 def to_a(*vars) a = super 2.times{ a.delete_at 0 } a end |
#to_msearch(*vars) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flex/template/search.rb', line 15 def to_msearch(*vars) vars = Vars.new(*vars) int = interpolate(vars, strict=true) header = {} header[:index] = int[:vars][:index] if int[:vars][:index] header[:type] = int[:vars][:type] if int[:vars][:type] [:search_type, :preferences, :routing].each do |k| header[k] = int[:vars][k] if int[:vars][k] || int[:vars][:params] && int[:vars][:params][k] end data, encoded = build_data(int, vars) "#{MultiJson.encode(header)}\n#{encoded}\n" end |