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.
130 131 132 133 134 135 136 |
# File 'lib/sunspot/field_factory.rb', line 130 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
138 139 140 141 142 143 144 |
# File 'lib/sunspot/field_factory.rb', line 138 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(:lng, coordinates.lng) end end |