lib/onebox/engine.rb in onebox-1.9.20 vs lib/onebox/engine.rb in onebox-1.9.21
- old
+ new
@@ -11,11 +11,10 @@
constant.to_s =~ /Onebox$/
end.map(&method(:const_get))
end
attr_reader :url, :uri
- attr_reader :cache
attr_reader :timeout
DEFAULT = {}
def options
@options
@@ -26,22 +25,23 @@
opt = opt.to_h if opt.instance_of?(OpenStruct)
@options.merge!(opt)
@options
end
- def initialize(link, cache = nil, timeout = nil)
+ def initialize(link, timeout = nil)
@options = DEFAULT
class_name = self.class.name.split("::").last.to_s
- self.options = Onebox.options[class_name] || {} #Set the engine options extracted from global options.
+ # Set the engine options extracted from global options.
+ self.options = Onebox.options[class_name] || {}
+
@url = link
@uri = URI(link)
if always_https?
@uri.scheme = 'https'
@url = @uri.to_s
end
- @cache = cache || Onebox.options.cache
@timeout = timeout || Onebox.options.timeout
end
# raises error if not defined in onebox engine.
# This is the output method for an engine.
@@ -60,16 +60,9 @@
def placeholder_html
to_html
end
private
-
- def record
- url_result = url
- result = cache.fetch(url_result) { data }
- cache[url_result] = result if cache.respond_to?(:key?)
- result
- end
# raises error if not defined in onebox engine
# in each onebox, uses either Nokogiri or StandardEmbed to get raw HTML from url
def raw
fail NoMethodError, "Engines need to implement this method"