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
22
23
24
25
26
# 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,
    :units         => options[:units],
    :method        => options[:method],
    :skip_index    => options[:skip_index] || false,
    :lookup        => options[:lookup],
    :language      => options[:language]
  )
end

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

Set attribute names and include the Geocoder module.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/geocoder/models/mongo_base.rb', line 31

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