Skip to content

Commit

Permalink
Extract long condition statement to its own method
Browse files Browse the repository at this point in the history
  • Loading branch information
joker1007 committed Jan 6, 2016
1 parent da53def commit 4b78f99
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/google/apis/core/upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class BaseUploadCommand < ApiCommand
# @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)
Expand All @@ -97,6 +97,12 @@ def prepare!
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
Expand Down

0 comments on commit 4b78f99

Please sign in to comment.