Class: Sunspot::FieldFactory::Coordinates
- Inherits:
-
Object
- Object
- Sunspot::FieldFactory::Coordinates
- Defined in:
- lib/sunspot/field_factory.rb
Instance Method Summary collapse
-
#initialize(name = nil, &block) ⇒ Coordinates
constructor
A new instance of Coordinates.
- #populate_document(document, model) ⇒ Object
Constructor Details
#initialize(name = nil, &block) ⇒ Coordinates
Returns a new instance of Coordinates.
127 128 129 130 131 132 133 |
# File 'lib/sunspot/field_factory.rb', line 127 def initialize(name = nil, &block) if block @data_extractor = DataExtractor::BlockExtractor.new(&block) else @data_extractor = DataExtractor::AttributeExtractor.new(name) end end |
Instance Method Details
#populate_document(document, model) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/sunspot/field_factory.rb', line 135 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 |