Skip to content

Instantly share code, notes, and snippets.

@justinko
Created October 17, 2012 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinko/3909084 to your computer and use it in GitHub Desktop.
Save justinko/3909084 to your computer and use it in GitHub Desktop.
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