Sha256: 724b0182c9116730347f553c8445f273c41beb75e0a9c68d703eab3f4ebe73f4

Contents?: true

Size: 646 Bytes

Versions: 5

Compression:

Stored size: 646 Bytes

Contents

module Searchjoy
  module Track
    def execute_with_track
      results = execute_without_track

      if options[:track]
        attributes = options[:track] == true ? {} : options[:track]

        search_type =
          if klass.respond_to?(:name) && klass.name.present?
            klass.name
          elsif options[:index_name]
            Array(options[:index_name]).map(&:to_s).sort.join(" ")
          else
            "All Indices"
          end

        results.search = Searchjoy::Search.create({search_type: search_type, query: term, results_count: results.total_count}.merge(attributes))
      end

      results
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
searchjoy-0.3.1 lib/searchjoy/track.rb
searchjoy-0.3.0 lib/searchjoy/track.rb
searchjoy-0.2.1 lib/searchjoy/track.rb
searchjoy-0.2.0 lib/searchjoy/track.rb
searchjoy-0.1.0 lib/searchjoy/track.rb