Class: Sunspot::FieldFactory::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/field_factory.rb

Overview

Base class for field factories.

Direct Known Subclasses

Dynamic, Join, Static

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}, &block) ⇒ Abstract

Returns a new instance of Abstract.



16
17
18
19
20
21
22
23
24
# File 'lib/sunspot/field_factory.rb', line 16

def initialize(name, options = {}, &block)
  @name = name.to_sym
  @data_extractor =
    if block
      DataExtractor::BlockExtractor.new(&block)
    else
      DataExtractor::AttributeExtractor.new(options.delete(:using) || name)
    end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/sunspot/field_factory.rb', line 14

def name
  @name
end

Instance Method Details

#populate_document(document, model, options = {}) ⇒ Object

Extract the encapsulated field’s data from the given model and add it into the Solr document for indexing. (noop here for joins)



30
31
# File 'lib/sunspot/field_factory.rb', line 30

def populate_document(document, model, options = {}) #:nodoc:
end