Class: Flash::Integration::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/flash/integration/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
# File 'lib/flash/integration/response.rb', line 8

def initialize(attributes)
  @request = attributes.fetch(:request)
  @status = attributes.fetch(:status)
  @headers = attributes[:headers] || {}
  @body = attributes[:body] || {}
  @time = attributes[:time] || Time.now.utc
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/flash/integration/response.rb', line 6

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/flash/integration/response.rb', line 6

def headers
  @headers
end

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/flash/integration/response.rb', line 6

def request
  @request
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/flash/integration/response.rb', line 6

def status
  @status
end

#timeObject (readonly)

Returns the value of attribute time.



6
7
8
# File 'lib/flash/integration/response.rb', line 6

def time
  @time
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  @status.between?(200, 299)
end