Made the builder more flexible by adding a callback parameter.
git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@27 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
parent
5b71f47a4d
commit
541054e88d
|
@ -42,6 +42,17 @@ module Google #:nodoc:
|
|||
def parser
|
||||
return @options[:parser]
|
||||
end
|
||||
|
||||
def build_request(*args, &block)
|
||||
if !args.empty? || block
|
||||
# Build the request!
|
||||
# TODO(bobaman): No-op / Debug code!
|
||||
return args
|
||||
else
|
||||
require 'google/api_client/discovery/method_builder'
|
||||
return ::Google::APIClient::MethodBuilder.new(self, :build_request)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,9 +33,10 @@ module Google #:nodoc:
|
|||
#
|
||||
# @param [Google::APIClient] client
|
||||
# The client the {MethodBuilder} will use to build requests.
|
||||
def initialize(client)
|
||||
def initialize(client, callback=:build_request)
|
||||
@segments = []
|
||||
@client = client
|
||||
@callback = callback
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -77,7 +78,7 @@ module Google #:nodoc:
|
|||
def method_missing(method, *args, &block)
|
||||
self << method
|
||||
if !args.empty? || block
|
||||
return @client.build_request(self.to_str, *args, &block)
|
||||
return @client.send(callback, self.to_str, *args, &block)
|
||||
else
|
||||
return self
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue