Sha256: 304305f097df581401267f4bd1a98f6bc856b8f622624dd5695035b913ac0567

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

require 'geocoder/models/base'

module Geocoder
  module Model
    module ActiveRecord
      include Base

      ##
      # Set attribute names and include the Geocoder module.
      #
      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]
        )
      end

      ##
      # Set attribute names and include the Geocoder module.
      #
      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]
        )
      end


      private # --------------------------------------------------------------

      def geocoder_file_name;   "active_record"; end
      def geocoder_module_name; "ActiveRecord"; end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
geocoder-1.1.9 lib/geocoder/models/active_record.rb
geocoder-1.1.8 lib/geocoder/models/active_record.rb
geocoder-1.1.7 lib/geocoder/models/active_record.rb
geocoder-sgonyea-1.1.6.1 lib/geocoder/models/active_record.rb
geocoder-1.1.6 lib/geocoder/models/active_record.rb
geocoder-1.1.5 lib/geocoder/models/active_record.rb
geocoder-1.1.4 lib/geocoder/models/active_record.rb
geocoder-1.1.3 lib/geocoder/models/active_record.rb
geocoder-1.1.2 lib/geocoder/models/active_record.rb