Module: Geocoder::Model::ActiveRecord

Includes:
Base
Defined in:
lib/geocoder/models/active_record.rb

Instance Method Summary collapse

Methods included from Base

#geocoder_options

Instance Method Details

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

Set attribute names and include the Geocoder module.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/geocoder/models/active_record.rb', line 11

def geocoded_by(address_attr, options = {}, &block)
  geocoder_init(
    :geocode       => true,
    :user_address  => address_attr,
    :latitude      => options[:latitude]  || :latitude,
    :longitude     => options[:longitude] || :longitude,
    :geocode_block => block,
    :units         => options[:units],
    :method        => options[:method],
    :lookup        => options[:lookup],
    :language      => options[:language],
    :params        => options[:params]
  )
end

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

Set attribute names and include the Geocoder module.



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

def reverse_geocoded_by(latitude_attr, longitude_attr, options = {}, &block)
  geocoder_init(
    :reverse_geocode => true,
    :fetched_address => options[:address] || :address,
    :latitude        => latitude_attr,
    :longitude       => longitude_attr,
    :reverse_block   => block,
    :units           => options[:units],
    :method          => options[:method],
    :lookup          => options[:lookup],
    :language        => options[:language],
    :params          => options[:params]
  )
end