Sha256: fad6d4a9b6000fea7151bf74dc163e7ddb2c9bd24a4d51b54642cdab61edfc06

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 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
        )
      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
        )
      end


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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
geocoder-1.1.1 lib/geocoder/models/active_record.rb
geocoder-1.1.0 lib/geocoder/models/active_record.rb
geocoder-1.0.5 lib/geocoder/models/active_record.rb
geocoder-1.0.4 lib/geocoder/models/active_record.rb
geocoder-1.0.3 lib/geocoder/models/active_record.rb
geocoder-1.0.2 lib/geocoder/models/active_record.rb
geocoder-1.0.1 lib/geocoder/models/active_record.rb
geocoder-1.0.0 lib/geocoder/models/active_record.rb
geocoder-0.9.13 lib/geocoder/models/active_record.rb
geocoder-0.9.12 lib/geocoder/models/active_record.rb