Class: HTTP::FormData::Multipart::Param
- Inherits:
-
Object
- Object
- HTTP::FormData::Multipart::Param
- Includes:
- Readable
- Defined in:
- lib/http/form_data/multipart/param.rb
Overview
Utility class to represent multi-part chunks
Class Method Summary collapse
-
.coerce(data) ⇒ Array<FormData::MultiPart::Param>
Flattens given
data
Hash into an array ofParam
's.
Instance Method Summary collapse
-
#initialize(name, value) ⇒ String
constructor
Initializes body part with headers and data.
Methods included from Readable
Constructor Details
#initialize(name, value) ⇒ String
Initializes body part with headers and data.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/http/form_data/multipart/param.rb', line 31 def initialize(name, value) @name = name.to_s @part = if value.is_a?(FormData::Part) value else FormData::Part.new(value) end @io = CompositeIO.new [header, @part, ] end |
Class Method Details
.coerce(data) ⇒ Array<FormData::MultiPart::Param>
Flattens given data
Hash into an array of Param
's.
Nested array are unwinded.
Behavior is similar to URL.encode_www_form
.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/http/form_data/multipart/param.rb', line 50 def self.coerce(data) params = [] data.each do |name, values| Array(values).each do |value| params << new(name, value) end end params end |