Sha256: 69f1428473daadcad5fbe06986491fe640740c0a6f348569b692750ecbda53c9

Contents?: true

Size: 814 Bytes

Versions: 6

Compression:

Stored size: 814 Bytes

Contents

module Picky

  class Category

    # Removes an indexed object with the
    # given id.
    #
    def remove id
      exact.remove id
      partial.remove id
    end

    # Adds and indexes this category of the
    # given object.
    #
    def add object
      tokens, _ = tokenizer.tokenize object.send(from)
      add_tokenized object.id, tokens
    end

    # Removes the object's id, and then
    # adds it again.
    #
    def replace object
      remove object.id
      add object
    end

    # For the given id, adds the list of
    # strings to the index for the given id.
    #
    def add_tokenized id, tokens
      tokens.each do |text|
        next unless text
        text = text.to_sym # TODO to_sym
        exact.add id, text
        partial.add_partialized id, text
      end
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
picky-3.4.3 lib/picky/category_realtime.rb
picky-3.4.2 lib/picky/category_realtime.rb
picky-3.4.1 lib/picky/category_realtime.rb
picky-3.4.0 lib/picky/category_realtime.rb
picky-3.3.3 lib/picky/category_realtime.rb
picky-3.3.2 lib/picky/category_realtime.rb