Sha256: 94e0773e3b0cfb74ad84f17598fa89d525a0472ed2a0790f7b0d9833be9bafbb

Contents?: true

Size: 835 Bytes

Versions: 36

Compression:

Stored size: 835 Bytes

Contents

module SearchFlip
  # The SearchFlip::Sortable mixin provides the chainable #source method to
  # use elasticsearch source filtering

  module Sourceable
    def self.included(base)
      base.class_eval do
        attr_accessor :source_value
      end
    end

    # Use to specify which fields of the source document you want Elasticsearch
    # to return for each matching result.
    #
    # @example
    #   CommentIndex.source([:id, :message]).search("hello world")
    #   CommentIndex.source(exclude: "description")
    #   CommentIndex.source(false)
    #
    # @param value Pass any allowed value to restrict the returned source
    #
    # @return [SearchFlip::Criteria] A newly created extended criteria

    def source(value)
      fresh.tap do |criteria|
        criteria.source_value = value
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
search_flip-4.0.0.beta5 lib/search_flip/sourceable.rb
search_flip-4.0.0.beta4 lib/search_flip/sourceable.rb
search_flip-3.2.1 lib/search_flip/sourceable.rb
search_flip-3.2.0 lib/search_flip/sourceable.rb
search_flip-4.0.0.beta3 lib/search_flip/sourceable.rb
search_flip-4.0.0.beta2 lib/search_flip/sourceable.rb
search_flip-4.0.0.beta1 lib/search_flip/sourceable.rb
search_flip-4.0.0.beta lib/search_flip/sourceable.rb
search_flip-3.1.2 lib/search_flip/sourceable.rb
search_flip-3.1.1 lib/search_flip/sourceable.rb
search_flip-3.1.0 lib/search_flip/sourceable.rb
search_flip-3.0.0 lib/search_flip/sourceable.rb
search_flip-3.0.0.beta6 lib/search_flip/sourceable.rb
search_flip-3.0.0.beta5 lib/search_flip/sourceable.rb
search_flip-3.0.0.beta4 lib/search_flip/sourceable.rb
search_flip-3.0.0.beta3 lib/search_flip/sourceable.rb