Update representable, mimetype dependencies + others
This commit is contained in:
1 parent
e6acda7118
commit
2c190e9745
7 files changed
+16
-19
No files matched your search
@@ -51,7 +51,7 @@ module Google
|
||||
query[FIELDS_PARAM] = normalize_fields_param(query[FIELDS_PARAM]) if query.key?(FIELDS_PARAM)
|
||||
if request_representation && request_object
|
||||
header['Content-Type'] ||= JSON_CONTENT_TYPE
|
||||
self.body = request_representation.new(request_object).to_json(skip_undefined: true)
|
||||
self.body = request_representation.new(request_object).to_json(user_options: { skip_undefined: true })
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
@@ -55,7 +55,7 @@ module Google
|
||||
def if_fn(name)
|
||||
ivar_name = "@#{name}".to_sym
|
||||
lambda do |opts|
|
||||
if opts[:skip_undefined]
|
||||
if opts[:user_options] && opts[:user_options][:skip_undefined]
|
||||
if respond_to?(:key?)
|
||||
self.key?(name) || instance_variable_defined?(ivar_name)
|
||||
else
|
||||
@@ -137,7 +137,7 @@ module Google
|
||||
|
||||
def to_json
|
||||
representation = self.class.const_get(:Representation)
|
||||
representation.new(self).to_json(skip_undefined: true)
|
||||
representation.new(self).to_json(user_options: { skip_undefined: true })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,13 +18,7 @@ require 'google/apis/core/api_command'
|
||||
require 'google/apis/errors'
|
||||
require 'addressable/uri'
|
||||
require 'tempfile'
|
||||
begin
|
||||
require 'mime/types/columnar'
|
||||
rescue LoadError
|
||||
# Temporary until next major bump when we can tighten
|
||||
# dependency to mime-types >-=3.0
|
||||
require 'mime-types'
|
||||
end
|
||||
require 'mime-types'
|
||||
|
||||
module Google
|
||||
module Apis
|
||||
@@ -59,6 +53,10 @@ module Google
|
||||
@close_io_on_finish = false
|
||||
elsif upload_source.is_a?(String)
|
||||
self.upload_io = File.new(upload_source, 'r')
|
||||
if upload_content_type.nil?
|
||||
type = MIME::Types.of(upload_source)
|
||||
upload_content_type = type.first.content_type unless type.nil? || type.empty?
|
||||
end
|
||||
@close_io_on_finish = true
|
||||
else
|
||||
fail Google::Apis::ClientError, 'Invalid upload source'
|
||||
|
||||
Reference in new issue
Block a user