Sha256: 2769d8dc4de36d1dd00a41bf26cb64e9dec3d757c0bae88d7fdc8b1d01ed6663

Contents?: true

Size: 976 Bytes

Versions: 1

Compression:

Stored size: 976 Bytes

Contents

#
#
class Category

  attr_reader :indexed_exact

  # Loads the index from cache.
  #
  def load_from_cache
    timed_exclaim %Q{"#{identifier}": Loading index from cache.}
    indexed_exact.load
    indexed_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? ? indexed_partial : indexed_exact
  end

  # The partial strategy defines whether to
  # really use the partial index.
  #
  def indexed_partial
    @partial_strategy.use_exact_for_partial? ? @indexed_exact : @indexed_partial
  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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.7.0 lib/picky/category_indexed.rb