Sha256: 430b707eb8f6564d3f281c2e3aedb0083e84a925f820ce977e6e7d0c7ae14f91
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
# Holds all indexes and provides operations # for extracting and working on them. # # Delegates a number of operations to the # indexes. # class Indexes attr_reader :indexes, :index_mapping delegate :size, :each, :to => :indexes each_delegate :reindex, :each_category, :to => :indexes def initialize clear_indexes end # Return the Indexes instance. # def self.instance @instance ||= new end instance_delegate :clear, :register, :reindex, :[], :to_s, :size, :each, :each_category # Clears the indexes and the mapping. # def clear_indexes @indexes = [] @index_mapping = {} end # Registers an index with the indexes. # def register index self.indexes << index self.index_mapping[index.name] = index end def self.register index self.instance.register index end # Extracts an index, given its identifier. # def [] identifier index_name = identifier.to_sym index_mapping[index_name] || raise_not_found(index_name) end # Raises a not found for the index. # def raise_not_found index_name raise %Q{Index "#{index_name}" not found. Possible indexes: "#{indexes.map(&:name).join('", "')}".} end # # def to_s indexes.indented_to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
picky-2.7.0 | lib/picky/indexes.rb |