1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/lib/puma/gems.rb

21 lines
519 B
Ruby
Raw Normal View History

2011-09-22 19:24:43 -07:00
module Puma
module Gems
class << self
def optional(library, version = nil)
begin
Kernel.require library
rescue LoadError, RuntimeError => e
begin
# ActiveSupport breaks 'require' by making it always return a true value
Kernel.require 'rubygems'
version ? gem(library, version) : gem(library)
retry
rescue Gem::LoadError, LoadError, RuntimeError
end
end
end
end
end
2011-09-22 19:24:43 -07:00
end