3 instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^respond_to\?$|^new$)/ }
6 class UnexecutedRequest < StandardError; end
7 def initialize(params,proc)
10 @method = params[:method]
11 @uri = params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
15 def result=(result_object)
16 @result = @proc.nil? ? result_object : @proc.call(result_object)
19 def exception_raised=(ex)
24 @exception.nil? ? false : raise(@exception)
28 super || @result.respond_to?(name)
35 def method_missing(name,*args,&proc)
39 raise UnexecutedRequest.new("You must execute the batch before accessing the result: #{@uri}")
41 @result.send(name,*args,&proc)