Module: Searchjoy::Track

Defined in:
lib/searchjoy/track.rb

Instance Method Summary collapse

Instance Method Details

#search_with_track(term, options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/searchjoy/track.rb', line 3

def search_with_track(term, options = {}, &block)
  results = search_without_track(term, options) do |body|
    block.call(body) if block
  end

  if options[:track]
    attributes = options[:track] == true ? {} : options[:track]
    results.search = Searchjoy::Search.create({search_type: name, query: term, results_count: results.total_count}.merge(attributes))
  end
  results
end