Sha256: c0d365d9b7892368dcdd64c3e71cc763896583c43541c0bfec0c5106dc5065c0
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
module Configuration class Type attr_reader :name, :source, :fields, :after_indexing, :result_type, :ignore_unassigned_tokens, :solr def initialize name, source, *fields, options if Configuration::Field === options fields << options options = {} end @name = name @source = source # dup, if field is reused. TODO Rewrite. @fields = fields.map { |field| field = field.dup; field.type = self; field } @after_indexing = options[:after_indexing] @result_type = options[:result_type] || name @ignore_unassigned_tokens = options[:ignore_unassigned_tokens] || false # TODO Move to query? @solr = options[:solr] || nil end def generate categories = fields.map { |field| field.generate } Index::Type.new name, result_type, ignore_unassigned_tokens, *categories end def table_name self # FIXME UGH, Remove anyway end def take_snapshot source.take_snapshot self end def index fields.each do |field| field.index end end def solr_fields solr ? fields.select { |field| !field.virtual? } : [] end # TODO Delegate to Solr handler. # def index_solr return unless solr @indexer = Indexers::Solr.new self @indexer.index end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
picky-0.0.3 | lib/picky/configuration/type.rb |
picky-0.0.2 | lib/picky/configuration/type.rb |