Skip to content
Paul Bergeron edited this page May 2, 2013 · 2 revisions

If there is another network call that can be used to fetch the reasource, it's possible to use another Rhod::Command once a failure has occurred.

require 'open-uri'
require 'rhod'

yahoo_fallback = Rhod::Command.new(
  :fallback => -> {""} # couldn't get anything
) do
  open("https://yahoo.com").read
end

Rhod.create_profile(:google, fallback: -> {yahoo_fallback.execute})

Rhod.with_google do
  open("http://google.com").read
end