Class: Taps::Multipart
- Inherits:
-
Object
- Object
- Taps::Multipart
- Defined in:
- lib/taps/multipart.rb
Defined Under Namespace
Classes: Container
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
- .create {|c| ... } ⇒ Object
-
.parse(response) ⇒ Object
response is a rest-client response.
Instance Method Summary collapse
- #content_type ⇒ Object
-
#initialize(opts = {}) ⇒ Multipart
constructor
A new instance of Multipart.
- #name ⇒ Object
- #original_filename ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Multipart
Returns a new instance of Multipart.
32 33 34 |
# File 'lib/taps/multipart.rb', line 32 def initialize(opts={}) @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
30 31 32 |
# File 'lib/taps/multipart.rb', line 30 def opts @opts end |
Class Method Details
.create {|c| ... } ⇒ Object
52 53 54 55 56 |
# File 'lib/taps/multipart.rb', line 52 def self.create c = Taps::Multipart::Container.new yield c c.generate end |
.parse(response) ⇒ Object
response is a rest-client response
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/taps/multipart.rb', line 59 def self.parse(response) content = response.to_s env = { 'CONTENT_TYPE' => response.headers[:content_type], 'CONTENT_LENGTH' => content.size, 'rack.input' => StringIO.new(content) } params = Rack::Utils::Multipart.parse_multipart(env) params.symbolize_keys! params end |
Instance Method Details
#content_type ⇒ Object
44 45 46 |
# File 'lib/taps/multipart.rb', line 44 def content_type opts[:content_type] || 'text/plain' end |
#name ⇒ Object
36 37 38 |
# File 'lib/taps/multipart.rb', line 36 def name opts[:name] end |
#original_filename ⇒ Object
48 49 50 |
# File 'lib/taps/multipart.rb', line 48 def original_filename opts[:original_filename] end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/taps/multipart.rb', line 40 def to_s opts[:payload] end |