class Anyfetch::OpenURI
Public Class Methods
new(*args)
click to toggle source
# File lib/anyfetch/open_uri.rb, line 6 def initialize(*args) raise NotImplementedError end
Public Instance Methods
open()
click to toggle source
Calls superclass method
# File lib/anyfetch/open_uri.rb, line 10 def open file = super(@uri, @options) if file.is_a?(StringIO) file = to_tempfile(file) end file.extend(OriginalFilename::ContentType) file end
Private Instance Methods
to_tempfile(io)
click to toggle source
OpenURI
returns either Tempfile or StringIO depending of the size of the response. We want to unify this and always return Tempfile.
# File lib/anyfetch/open_uri.rb, line 25 def to_tempfile(io) tempfile = Tempfile.new('open-uri') tempfile.binmode ::OpenURI::Meta.init(tempfile, io) tempfile << io.string tempfile end