Module: Geocoder::ModelMethods

Defined in:
lib/geocoder/railtie.rb

Overview

Methods available in the model class before Geocoder is invoked.

Instance Method Summary collapse

Instance Method Details

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

Set attribute names and include the Geocoder module.



33
34
35
36
37
38
39
40
41
# File 'lib/geocoder/railtie.rb', line 33

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
  )
end

#geocoder_optionsObject



56
57
58
# File 'lib/geocoder/railtie.rb', line 56

def geocoder_options
  @geocoder_options
end

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

Set attribute names and include the Geocoder module.



46
47
48
49
50
51
52
53
54
# File 'lib/geocoder/railtie.rb', line 46

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
  )
end