Allow options when executing batch requests (#48)

This commit is contained in:
Steven Bazyl 2013-05-13 15:19:25 -07:00
parent 794c6a90f7
commit aa7a254d23
2 changed files with 18 additions and 4 deletions

View File

@ -542,10 +542,9 @@ module Google
# #
# @see Google::APIClient#generate_request # @see Google::APIClient#generate_request
def execute(*params) def execute(*params)
if params.last.kind_of?(Google::APIClient::Request) && if params.first.kind_of?(Google::APIClient::Request)
params.size == 1 request = params.shift
request = params.pop options = params.shift || {}
options = {}
else else
# This block of code allows us to accept multiple parameter passing # This block of code allows us to accept multiple parameter passing
# styles, and maintaining some backwards compatibility. # styles, and maintaining some backwards compatibility.

View File

@ -143,6 +143,21 @@ describe Google::APIClient do
) )
end end
it 'should accept options with batch/request style execute' do
client.authorization.access_token = "abcdef"
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
request = client.generate_request(
:api_method => @prediction.training.insert,
:parameters => {'data' => '12345'}
)
client.execute(
request,
:authorization => new_auth,
:connection => @connection
)
end
it 'should accept options in array style execute' do it 'should accept options in array style execute' do
client.authorization.access_token = "abcdef" client.authorization.access_token = "abcdef"
new_auth = Signet::OAuth2::Client.new(:access_token => '12345') new_auth = Signet::OAuth2::Client.new(:access_token => '12345')