Extract long condition statement to its own method
This commit is contained in:
1 parent
da53defdc8
commit
4b78f99f7a
1 file changed
+7
-1
@@ -82,7 +82,7 @@ module Google
|
||||
# @raise [Google::Apis::ClientError] if upload source is invalid
|
||||
def prepare!
|
||||
super
|
||||
if upload_source.is_a?(IO) || upload_source.is_a?(StringIO) || upload_source.is_a?(Tempfile)
|
||||
if streamable?(upload_source)
|
||||
self.upload_io = UploadIO.from_io(upload_source, content_type: upload_content_type)
|
||||
@close_io_on_finish = false
|
||||
elsif upload_source.is_a?(String)
|
||||
@@ -97,6 +97,12 @@ module Google
|
||||
def release!
|
||||
upload_io.close if @close_io_on_finish
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def streamable?(upload_source)
|
||||
upload_source.is_a?(IO) || upload_source.is_a?(StringIO) || upload_source.is_a?(Tempfile)
|
||||
end
|
||||
end
|
||||
|
||||
# Implementation of the raw upload protocol
|
||||
|
||||
Reference in new issue
Block a user