Sha256: 3f256b76aa80cd4210ba7a4c7ea319c892d52b9990288e2c2cc7288153c2bc68

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

module Indexed # :nodoc:all

  # Registers the indexes held at runtime, for queries.
  #
  class Indexes

    attr_reader :indexes, :index_mapping

    each_delegate :load_from_cache,
                  :to => :indexes

    def initialize
      clear
    end

    def to_s
      indexes.indented_to_s
    end

    # Clears the indexes and the mapping.
    #
    def clear
      @indexes       = []
      @index_mapping = {}
    end

    # Reloads all indexes, one after another,
    # in the order they were added.
    #
    def reload
      load_from_cache
    end

    # Registers an index with the indexes.
    #
    def register index
      self.indexes << index
      self.index_mapping[index.name] = index
    end

    # Load each index, and analyze it.
    #
    # Returns a hash with the findings.
    #
    def analyze
      result = {}
      self.indexes.each do |index|
        index.analyze result
      end
      result
    end

    # Extracts an index, given its identifier.
    #
    def [] identifier
      index_mapping[identifier.to_sym]
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
picky-2.5.0 lib/picky/indexed/indexes.rb
picky-2.4.3 lib/picky/indexed/indexes.rb
picky-2.4.2 lib/picky/indexed/indexes.rb
picky-2.4.1 lib/picky/indexed/indexes.rb
picky-2.4.0 lib/picky/indexed/indexes.rb
picky-2.3.0 lib/picky/indexed/indexes.rb
picky-2.2.1 lib/picky/indexed/indexes.rb
picky-2.2.0 lib/picky/indexed/indexes.rb
picky-2.1.2 lib/picky/indexed/indexes.rb
picky-2.1.1 lib/picky/indexed/indexes.rb
picky-2.1.0 lib/picky/indexed/indexes.rb
picky-2.0.0 lib/picky/indexed/indexes.rb
picky-2.0.0.pre3 lib/picky/indexed/indexes.rb
picky-2.0.0.pre2 lib/picky/indexed/indexes.rb