Module: Dagger::Response

Defined in:
lib/dagger/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject (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

#codeObject Also known as: status



20
21
22
# File 'lib/dagger/response.rb', line 20

def code
  super.to_i
end

#content_typeObject



26
27
28
# File 'lib/dagger/response.rb', line 26

def content_type
  self['Content-Type']
end

#dataObject



48
49
50
# File 'lib/dagger/response.rb', line 48

def data
  @data ||= Parsers.new(self).process
end

#headersObject



16
17
18
# File 'lib/dagger/response.rb', line 16

def headers
  to_hash # from Net::HTTPHeader module
end

#redirect?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/dagger/response.rb', line 36

def redirect?
  [301, 302, 303, 307].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?

Returns:

  • (Boolean)


30
31
32
# File 'lib/dagger/response.rb', line 30

def success?
  [200, 201].include?(code)
end

#to_aObject



44
45
46
# File 'lib/dagger/response.rb', line 44

def to_a
  [code, headers, to_s]
end

#to_sObject



40
41
42
# File 'lib/dagger/response.rb', line 40

def to_s
  body.to_s
end