Skip to content
Snippets Groups Projects
Commit 4dd52395 authored by Alex Reisner's avatar Alex Reisner
Browse files

Refactor ESRI lookup to isolate token generation.

parent 83417eb7
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ module Geocoder::Lookup ...@@ -48,7 +48,7 @@ module Geocoder::Lookup
end end
def token def token
fetch_and_save_token! if !valid_token_configured? and configuration.api_key create_and_save_token! if !valid_token_configured? and configuration.api_key
configuration[:token].to_s unless configuration[:token].nil? configuration[:token].to_s unless configuration[:token].nil?
end end
...@@ -56,8 +56,15 @@ module Geocoder::Lookup ...@@ -56,8 +56,15 @@ module Geocoder::Lookup
!configuration[:token].nil? and configuration[:token].active? !configuration[:token].nil? and configuration[:token].active?
end end
def fetch_and_save_token! def create_and_save_token!
token_instance = Geocoder::EsriToken.generate_token(*configuration.api_key) save_token!(create_token)
end
def create_token
Geocoder::EsriToken.generate_token(*configuration.api_key)
end
def save_token!(token_instance)
Geocoder.configure(:esri => Geocoder.config[:esri].merge({:token => token_instance})) Geocoder.configure(:esri => Geocoder.config[:esri].merge({:token => token_instance}))
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment