Class: Cfan122::Operation::Response
- Inherits:
-
Object
- Object
- Cfan122::Operation::Response
- Defined in:
- lib/cfan122/operation.rb
Direct Known Subclasses
ExamAgency::Response, ExamLocation::Response, ExamPlanDetail::Response, ExamPlanList::Response, ExamPlanResult::Response, ExamStudentList::Response, ExamSubject::Response
Instance Attribute Summary collapse
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(operation) ⇒ Response
constructor
A new instance of Response.
- #to_json ⇒ Object
Constructor Details
#initialize(operation) ⇒ Response
Returns a new instance of Response.
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
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
51 52 53 |
# File 'lib/cfan122/operation.rb', line 51 def operation @operation end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
51 52 53 |
# File 'lib/cfan122/operation.rb', line 51 def request @request end |
#response ⇒ Object (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_json ⇒ Object
60 61 62 |
# File 'lib/cfan122/operation.rb', line 60 def to_json response.body.blank? ? {} : JSON.parse(response.body) end |