module Geocoder::Store::Base

def do_lookup(reverse = false)


Geocoder::Result objects).
given two-arguments: the object being geocoded and an array of
block (given to geocoded_by or reverse_geocoded_by). The block is
geocoded_by or reverse_geocoded_by) and handle the results with the
Look up geographic data based on object attributes (configured in
#
def do_lookup(reverse = false)
  options = self.class.geocoder_options
  if reverse and options[:reverse_geocode]
    query = to_coordinates
  elsif !reverse and options[:geocode]
    query = send(options[:user_address])
  else
    return
  end
  if (results = Geocoder.search(query)).size > 0
    # execute custom block, if specified in configuration
    block_key = reverse ? :reverse_block : :geocode_block
    if custom_block = options[block_key]
      custom_block.call(self, results)
    # else execute block passed directly to this method,
    # which generally performs the "auto-assigns"
    elsif block_given?
      yield(self, results)
    end
  end
end