Sha256: 6eb83176dd3a72303bd3bb07450e3a5eb14e6f4ba988962b6d0fa290067b3396

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

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, where = :unshift
      tokens, _ = tokenizer.tokenize object.send(from)
      add_tokenized object.id, tokens, where
    end

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

    # For the given id, adds the list of
    # strings to the index for the given id.
    #
    def add_tokenized id, tokens, where = :unshift
      tokens.each { |text| add_tokenized_token id, text, where }
    end

    #
    #
    def add_tokenized_token id, text, where = :unshift
      return unless text
      id   = id.send key_format # TODO Speed this up!
      # text = text.to_sym if @symbols # TODO Symbols.
      exact.add id, text, where
      partial.add_partialized id, text, where
    end

    # Clears the realtime mapping.
    #
    def clear_realtime_mapping
      exact.clear_realtime_mapping
      partial.clear_realtime_mapping
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-3.5.0 lib/picky/category_realtime.rb