Sha256: 31408feb4b1c01f0f5d00bf6e3faf75855c7ebf388d9105c16fe317ee418cd1b

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

module Picky

  #
  #
  class Category

    # Loads the index from cache.
    #
    def load_from_cache
      timed_exclaim %Q{"#{identifier}": Loading index from cache.}
      clear_realtime_mapping
      exact.load
      partial.load
    end
    alias reload load_from_cache

    # Gets the weight for this token's text.
    #
    def weight token
      bundle_for(token).weight token.text
    end

    # Gets the ids for this token's text.
    #
    def ids token
      bundle_for(token).ids token.text
    end

    # Returns the right index bundle for this token.
    #
    def bundle_for token
      token.partial? ? partial : exact
    end

    # Returns a combination for the token,
    # or nil, if there is none.
    #
    def combination_for token
      weight(token) && Query::Combination.new(token, self)
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
picky-3.5.4 lib/picky/category_indexed.rb
picky-3.5.3 lib/picky/category_indexed.rb
picky-3.5.2 lib/picky/category_indexed.rb
picky-3.5.1 lib/picky/category_indexed.rb
picky-3.5.0 lib/picky/category_indexed.rb