Sha256: df86aaf1642c4a679e83d26a82d5861f3fad40faef7dffcdb06d30c24de346ce

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 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, :to => :default_index
    
    #
    #
    def type name, *fields
      types << Type.new(name, *fields)
    end
    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.3 lib/picky/configuration/indexes.rb
picky-0.0.2 lib/picky/configuration/indexes.rb