lib/onebox/preview.rb in onebox-2.2.12 vs lib/onebox/preview.rb in onebox-2.2.13
- old
+ new
@@ -1,10 +1,9 @@
# frozen_string_literal: true
module Onebox
class Preview
-
# see https://bugs.ruby-lang.org/issues/14688
client_exception = defined?(Net::HTTPClientException) ? Net::HTTPClientException : Net::HTTPServerException
WEB_EXCEPTIONS ||= [client_exception, OpenURI::HTTPError, Timeout::Error, Net::HTTPError, Errno::ECONNREFUSED]
def initialize(link, options = Onebox.options)
@@ -83,10 +82,10 @@
Sanitize.fragment(html, config)
end
def engine
return nil unless @engine_class
- return @engine if @engine
+ return @engine if defined?(@engine)
@engine = @engine_class.new(@url)
@engine.options = @options
@engine
end