Module: HTTMultiParty
- Included in:
- Basement
- Defined in:
- lib/httmultiparty.rb,
lib/httmultiparty/version.rb
Defined Under Namespace
Modules: ClassMethods, Multipartable
Classes: Basement, MultipartPost, MultipartPut
Constant Summary
collapse
- TRANSFORMABLE_TYPES =
[File, Tempfile]
- QUERY_STRING_NORMALIZER =
Proc.new do |params|
HTTMultiParty.flatten_params(params).map do |(k,v)|
[k, TRANSFORMABLE_TYPES.include?(v.class) ? HTTMultiParty.file_to_upload_io(v) : v]
end
end
- VERSION =
'0.3.8'
Class Method Summary
collapse
Class Method Details
.delete(*args) ⇒ Object
61
62
63
|
# File 'lib/httmultiparty.rb', line 61
def self.delete(*args)
Basement.delete(*args)
end
|
.file_to_upload_io(file) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/httmultiparty.rb', line 21
def self.file_to_upload_io(file)
if file.respond_to? :original_filename
filename = file.original_filename
else
filename = File.split(file.path).last
end
content_type = 'application/octet-stream'
UploadIO.new(file, content_type, filename)
end
|
.flatten_params(params = {}, prefix = '') ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/httmultiparty.rb', line 31
def self.flatten_params(params={}, prefix='')
flattened = []
params.each do |(k,v)|
if params.is_a?(Array)
v = k
k = ""
end
flattened_key = prefix == "" ? "#{k}" : "#{prefix}[#{k}]"
if v.is_a?(Hash) || v.is_a?(Array)
flattened += flatten_params(v, flattened_key)
else
flattened << [flattened_key, v]
end
end
flattened
end
|
.get(*args) ⇒ Object
49
50
51
|
# File 'lib/httmultiparty.rb', line 49
def self.get(*args)
Basement.get(*args)
end
|
.head(*args) ⇒ Object
65
66
67
|
# File 'lib/httmultiparty.rb', line 65
def self.head(*args)
Basement.head(*args)
end
|
.included(base) ⇒ Object
16
17
18
19
|
# File 'lib/httmultiparty.rb', line 16
def self.included(base)
base.send :include, HTTParty
base.extend ClassMethods
end
|
.options(*args) ⇒ Object
69
70
71
|
# File 'lib/httmultiparty.rb', line 69
def self.options(*args)
Basement.options(*args)
end
|
.post(*args) ⇒ Object
53
54
55
|
# File 'lib/httmultiparty.rb', line 53
def self.post(*args)
Basement.post(*args)
end
|
.put(*args) ⇒ Object
57
58
59
|
# File 'lib/httmultiparty.rb', line 57
def self.put(*args)
Basement.put(*args)
end
|