Sha256: 128b3c85344ec5c38b4058c7f6852b4db942ff6dc124e6f4a7de0ae82397d312
Contents?: true
Size: 660 Bytes
Versions: 3
Compression:
Stored size: 660 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 raise e if e end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.3 | lib/wayfarer/networking/context.rb |
wayfarer-0.4.2 | lib/wayfarer/networking/context.rb |
wayfarer-0.4.1 | lib/wayfarer/networking/context.rb |