Sha256: e64054449a15cc700f84995b4f10fc857153ee6460bea60f44604a655e2e77f7
Contents?: true
Size: 722 Bytes
Versions: 2
Compression:
Stored size: 722 Bytes
Contents
# frozen_string_literal: true module Wayfarer module Networking Context = Struct.new(:strategy) do def fetch(url) supervise { strategy.fetch(instance, url) } end def live supervise { strategy.live(instance) } end def renew strategy.destroy(instance) ensure @instance = nil end def instance @instance ||= strategy.create end private def supervise yield rescue *strategy.renew_on => e renew ensure # If renewing raises, re-raise the originally caught exception # TODO: Not nice this effectively swallows exceptions raise e if e end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.5 | lib/wayfarer/networking/context.rb |
wayfarer-0.4.4 | lib/wayfarer/networking/context.rb |