3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/http_client/methods.rb', line 3
def self.create_type(&native_request_factory)
Class.new do
def initialize(path, params = {})
@path = path
@params = params
@headers = {}
end
def ()
@headers.merge!()
end
define_method(:create_native_request) do |uri_builder, encoding|
params = @params.collect { |key, value| BasicNameValuePair.new(key.to_s, value.to_s) }
request = native_request_factory.call(uri_builder, @path, params, encoding)
@headers.each { |name, value| request.(name.to_s, value.to_s) }
request
end
end
end
|