Sha256: f6889421a19f1db477c866a9a699efb8d5e94987cfd348459c5f653cb24d2408

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

module Configuration

  class Indexes
    
    attr_reader :types
    
    def initialize *types
      @types = types
    end
    
    #
    #
    def default_index
      Tokenizers::Index
    end
    
    # Delegates
    #
    delegate :illegal_characters, :contract_expressions, :stopwords, :split_text_on, :normalize_words, :illegal_characters_after_splitting, :to => :default_index
    
    def type name, *fields
      types << Type.new(name, *fields)
    end
    alias add_index type
    def field name, options = {}
      Field.new name, options
    end
    
    #
    #
    def take_snapshot *type_names
      only_if_included_in type_names do |type|
        type.take_snapshot
      end
    end
    def index *type_names
      only_if_included_in type_names do |type|
        type.index
      end
    end
    def index_solr *type_names
      only_if_included_in type_names do |type|
        type.index_solr
      end
    end
    
    #
    #
    def only_if_included_in type_names = []
      type_names = types.map(&:name) if type_names.empty?
      types.each do |type|
        next unless type_names.include?(type.name)
        yield type
      end
    end
    
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picky-0.0.9 lib/picky/configuration/indexes.rb
picky-0.0.8 lib/picky/configuration/indexes.rb