class BtcPrice::ServicesHealth

Public Instance Methods

healthy?() click to toggle source
# File lib/btc_price/services_health.rb, line 5
def healthy?
  # Check if Coinbase API is available
  begin
    response = CoinbaseGateway.new.send(:request_price)
  rescue OpenURI::HTTPError => error
    raise CoinbaseApiError, error.io
  end

  check_status(response)
end

Private Instance Methods

check_status(response) click to toggle source
# File lib/btc_price/services_health.rb, line 18
def check_status(response)
  # Inspect the response status
  response.status.first == "200" ? true : false
end