Module: Geocoder::Model::MongoBase

Included in:
MongoMapper, Mongoid
Defined in:
lib/geocoder/models/mongo_base.rb

Instance Method Summary collapse

Instance Method Details

#geocoded_by(address_attr, options = {}, &block) ⇒ Object

Set attribute names and include the Geocoder module.



14
15
16
17
18
19
20
21
# File 'lib/geocoder/models/mongo_base.rb', line 14

def geocoded_by(address_attr, options = {}, &block)
  geocoder_init(
    :geocode       => true,
    :user_address  => address_attr,
    :coordinates   => options[:coordinates] || :coordinates,
    :geocode_block => block
  )
end

#reverse_geocoded_by(coordinates_attr, options = {}, &block) ⇒ Object

Set attribute names and include the Geocoder module.



26
27
28
29
30
31
32
33
# File 'lib/geocoder/models/mongo_base.rb', line 26

def reverse_geocoded_by(coordinates_attr, options = {}, &block)
  geocoder_init(
    :reverse_geocode => true,
    :fetched_address => options[:address] || :address,
    :coordinates     => coordinates_attr,
    :reverse_block   => block
  )
end