diff --git a/lib/google/api_client.rb b/lib/google/api_client.rb index 907170caa..9c6ffd3ee 100644 --- a/lib/google/api_client.rb +++ b/lib/google/api_client.rb @@ -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 diff --git a/lib/google/api_client/discovery/method_builder.rb b/lib/google/api_client/discovery/method_builder.rb index 06a1ae00d..ed1f69ea7 100644 --- a/lib/google/api_client/discovery/method_builder.rb +++ b/lib/google/api_client/discovery/method_builder.rb @@ -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