Class: Sunspot::FieldFactory::Coordinates

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

Overview

XXX Right now this doubles as a Field and a FieldFactory - good idea?

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Coordinates

Returns a new instance of Coordinates.



128
129
130
# File 'lib/sunspot/field_factory.rb', line 128

def initialize(name)
  @data_extractor = DataExtractor::AttributeExtractor.new(name)
end

Instance Method Details

#populate_document(document, model) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/sunspot/field_factory.rb', line 132

def populate_document(document, model)
  if coordinates = @data_extractor.value_for(model)
    coordinates = Util::Coordinates.new(coordinates)
    document.add_field(:lat, coordinates.lat)
    document.add_field(:long, coordinates.lng)
  end
end