Created
October 17, 2012 23:56
-
-
Save justinko/3909084 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
class Post | |
FetchError = Class.new(StandardError) | |
def self.able_to_fetch? | |
# https://github.com/djberg96/net-ping | |
# `ping?` determines its boolean by rescuing an exception (SocketError). | |
# Where that exception is handled is up to you. Do you want it to occur in | |
# a gem (net-ping) or in your controller? Either way, doesn't fucking matter, | |
# someone's gotta do it. | |
Net::Ping::HTTP.new(service_url).ping? | |
end | |
def self.fetch_all_posts | |
service_call | |
rescue ServiceError | |
raise FetchError | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment