Class: Cfan122::Operation::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cfan122/operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation) ⇒ Response

Returns a new instance of Response.

Raises:



53
54
55
56
57
58
# File 'lib/cfan122/operation.rb', line 53

def initialize operation
  @operation = operation
  @response = operation.execute
  @request = response.request
  raise ResponseError.new('Request Error!', response.code) if response.code != 200
end

Instance Attribute Details

#operationObject (readonly)

Returns the value of attribute operation.



51
52
53
# File 'lib/cfan122/operation.rb', line 51

def operation
  @operation
end

#requestObject (readonly)

Returns the value of attribute request.



51
52
53
# File 'lib/cfan122/operation.rb', line 51

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



51
52
53
# File 'lib/cfan122/operation.rb', line 51

def response
  @response
end

Instance Method Details

#to_jsonObject



60
61
62
# File 'lib/cfan122/operation.rb', line 60

def to_json
  response.body.blank? ? {} : JSON.parse(response.body)
end