Sha256: 0afcb49b3bf4dcf40b607eb99a7a3b7152acdb8890709a99fbb3d9dfd06946d6

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 Bytes

Contents

# Comfortable API convenience class, splits methods to indexes.
#
class IndexBundle # :nodoc:all

  attr_reader :indexes, :index_mapping, :indexing, :indexed

  delegate :size,
           :each,
           :to => :indexes

  delegate :analyze,
           :load_from_cache,
           :reload,
           :to => :indexed

  delegate :check_caches,
           :find,
           :index,
           :index_for_tests,
           :to => :indexing

  def initialize
    @indexes = []
    @index_mapping = {}

    @indexed  = Indexed::Indexes.new
    @indexing = Indexing::Indexes.new
  end

  def register index
    self.indexes << index
    self.index_mapping[index.name] = index

    indexing.register index.internal_indexing
    indexed.register  index.internal_indexed
  end

  def [] name
    name = name.to_sym

    self.index_mapping[name]
  end
  
  def to_s
    indexes.map &:to_stats
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picky-2.5.2 lib/picky/index_bundle.rb
picky-2.5.1 lib/picky/index_bundle.rb