Class: RequestBody
- Inherits:
-
Object
- Object
- RequestBody
- Defined in:
- lib/primate/request_body.rb
Instance Method Summary collapse
- #blob ⇒ Object
- #form ⇒ Object
-
#initialize(body, helpers) ⇒ RequestBody
constructor
A new instance of RequestBody.
- #json ⇒ Object
- #multipart ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(body, helpers) ⇒ RequestBody
Returns a new instance of RequestBody.
17 18 19 20 |
# File 'lib/primate/request_body.rb', line 17 def initialize(body, helpers) @body = body @helpers = helpers end |
Instance Method Details
#blob ⇒ Object
50 51 52 |
# File 'lib/primate/request_body.rb', line 50 def blob Primate::Readable.new(@body.blobSync, @body.blobTypeSync.to_s) end |
#form ⇒ Object
30 31 32 |
# File 'lib/primate/request_body.rb', line 30 def form JSON.parse(@body.formSync.to_s) end |
#json ⇒ Object
22 23 24 |
# File 'lib/primate/request_body.rb', line 22 def json JSON.parse(@body.jsonSync.to_s) end |
#multipart ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/primate/request_body.rb', line 34 def multipart form = JSON.parse(@body.formSync.to_s) files_js = @body.filesSync files = Array.new(files_js[:length].to_i) do |i| f = files_js[i] Primate::UploadedFile.new( field: f['field'].to_s, name: f['name'].to_s, type: f['type'].to_s, size: f['size'].to_i, bytes: f['bytes'] ) end Multipart.new(form, files) end |
#text ⇒ Object
26 27 28 |
# File 'lib/primate/request_body.rb', line 26 def text @body.textSync.to_s end |