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:
bobaman@google.com committed 2010-08-24 21:59:53 +00:00
1 parent 5b71f47a4d
commit 541054e88d
2 files changed
+14 -2

No files matched your search

@@ -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