Created
February 21, 2012 23:03
-
-
Save azuby/1879653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_location | |
response = get_location_response | |
if response.success? | |
if status = response.to_array(:return, :location_response, :status).first == "FOUND" | |
return response | |
elsif error = response.to_array(:return, :msisdn_error).first | |
raise LocationError, error[:error_message] | |
raise APIError, "A problem was encountered with the API response: #{response.inspect}" | |
else | |
raise APIError, "A problem was encountered with the API response: #{response.inspect}" | |
end | |
else | |
raise APIError, "Connection to API unsuccessful: #{response.inspect}" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Locator | |
@queue = :location_queue | |
def self.perform | |
begin | |
location = get_location | |
# do something useful with location | |
rescue LocationError => error | |
# do something useful with location error | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment