Sha256: 6903770e47f465adfe0998002b2131210655a1e4808b664e47a2696ad03fc629

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

module Searchkick
  class Relation
    # note: modifying body directly is not supported
    # and has no impact on query after being executed
    # TODO freeze body object?
    delegate :body, :params, to: :@query
    delegate_missing_to :private_execute

    def initialize(model, term = "*", **options)
      @query = Query.new(model, term, **options)
    end

    # same as Active Record
    def inspect
      entries = results.first(11).map!(&:inspect)
      entries[10] = "..." if entries.size == 11
      "#<#{self.class.name} [#{entries.join(', ')}]>"
    end

    def execute
      Searchkick.warn("The execute method is no longer needed")
      private_execute
      self
    end

    private

    def private_execute
      @execute ||= @query.execute
    end

    def query
      @query
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
searchkick-5.0.1 lib/searchkick/relation.rb
searchkick-5.0.0 lib/searchkick/relation.rb