Class: GeocoderWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/geocoder_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(object_type, object_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/geocoder_worker.rb', line 6

def perform(object_type, object_id)
  @object = object_type.singularize.classify.constantize.find(object_id)
  @results = []
  @searches = %i[search_city search_address search_ip]

  while @results.empty? && @searches.any?
    search = @searches.pop
    method(search).call
  end

  return if @results.empty?

  set_latitude_longitude
  @object.save!
end