Skip to content

Commit

Permalink
Allow options when executing batch requests (googleapis#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrrrl committed May 13, 2013
1 parent 794c6a9 commit aa7a254
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/google/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,9 @@ def generate_request(options={})
#
# @see Google::APIClient#generate_request
def execute(*params)
if params.last.kind_of?(Google::APIClient::Request) &&
params.size == 1
request = params.pop
options = {}
if params.first.kind_of?(Google::APIClient::Request)
request = params.shift
options = params.shift || {}
else
# This block of code allows us to accept multiple parameter passing
# styles, and maintaining some backwards compatibility.
Expand Down
15 changes: 15 additions & 0 deletions spec/google/api_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@
)
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
client.authorization.access_token = "abcdef"
new_auth = Signet::OAuth2::Client.new(:access_token => '12345')
Expand Down

0 comments on commit aa7a254

Please sign in to comment.