Sha256: d1ed38d9a67ae614cbe5dd9bd66a92cfe585196fb5e4a7d4a9551a977b1ca613

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 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
    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

4 entries across 4 versions & 1 rubygems

Version Path
picky-0.0.7 lib/picky/configuration/indexes.rb
picky-0.0.6 lib/picky/configuration/indexes.rb
picky-0.0.5 lib/picky/configuration/indexes.rb
picky-0.0.4 lib/picky/configuration/indexes.rb