Module: Dagger::Response
- Defined in:
- lib/dagger/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Class Method Summary collapse
Instance Method Summary collapse
- #code ⇒ Object (also: #status)
- #content_type ⇒ Object
- #data ⇒ Object
- #headers ⇒ Object
- #redirect? ⇒ Boolean
- #set_body(string) ⇒ Object
- #success? ⇒ Boolean (also: #ok?)
- #to_a ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/dagger/response.rb', line 5 def body @body end |
Class Method Details
.extended(base) ⇒ Object
7 8 9 |
# File 'lib/dagger/response.rb', line 7 def self.extended(base) # puts base.inspect end |
Instance Method Details
#code ⇒ Object Also known as: status
20 21 22 |
# File 'lib/dagger/response.rb', line 20 def code super.to_i end |
#content_type ⇒ Object
26 27 28 |
# File 'lib/dagger/response.rb', line 26 def content_type self['Content-Type'] end |
#data ⇒ Object
48 49 50 |
# File 'lib/dagger/response.rb', line 48 def data @data ||= Parsers.new(self).process end |
#headers ⇒ Object
16 17 18 |
# File 'lib/dagger/response.rb', line 16 def headers to_hash # from Net::HTTPHeader module end |
#redirect? ⇒ Boolean
36 37 38 |
# File 'lib/dagger/response.rb', line 36 def redirect? [301, 302, 303, 307, 308].include?(code) end |
#set_body(string) ⇒ Object
11 12 13 14 |
# File 'lib/dagger/response.rb', line 11 def set_body(string) raise "Body is set!" if body @body = string end |
#success? ⇒ Boolean Also known as: ok?
30 31 32 |
# File 'lib/dagger/response.rb', line 30 def success? [200, 201].include?(code) end |
#to_a ⇒ Object
44 45 46 |
# File 'lib/dagger/response.rb', line 44 def to_a [code, headers, to_s] end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/dagger/response.rb', line 40 def to_s body.to_s end |