Sha256: 61757911e51442d912bcf66bf28978a0eaf959dd962623215c2c7e4921025442

Contents?: true

Size: 1.34 KB

Versions: 30

Compression:

Stored size: 1.34 KB

Contents

module Picky

  module Query

    class Indexes
      
      # Checks if multiple backends are used in the same search instance.
      #
      # Using multiple backends for the same search are not yet possible.
      #
      class Check

        class << self

          # Returns the right combinations strategy for
          # a number of query indexes.
          #
          # Currently it isn't possible using Memory and Redis etc.
          # indexes in the same query index group.
          #
          # Picky will raise a Query::Indexes::DifferentBackendsError.
          #
          def check_backends indexes
            backends = indexes.map &:backend
            backends.uniq! &:class
            raise_different backends if backends.size > 1
            backends
          end
          def raise_different backends
            raise DifferentBackendsError.new(backends)
          end

        end
        
      end
      
      # Currently it isn't possible using Memory and Redis etc.
      # indexes in the same query index group.
      #
      class DifferentBackendsError < StandardError
        def initialize backends
          @backends = backends
        end
        def to_s
          "Currently it isn't possible to mix Indexes with backends #{@backends.join(" and ")} in the same Search instance."
        end
      end
      
    end

  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
picky-4.22.0 lib/picky/query/indexes/check.rb
picky-4.21.2 lib/picky/query/indexes/check.rb
picky-4.21.1 lib/picky/query/indexes/check.rb
picky-4.21.0 lib/picky/query/indexes/check.rb
picky-4.20.2 lib/picky/query/indexes/check.rb
picky-4.20.1 lib/picky/query/indexes/check.rb
picky-4.20.0 lib/picky/query/indexes/check.rb
picky-4.19.7 lib/picky/query/indexes/check.rb
picky-4.19.6 lib/picky/query/indexes/check.rb
picky-4.19.5 lib/picky/query/indexes/check.rb