Class: Mushikago::Http::Response
- Inherits:
-
Object
- Object
- Mushikago::Http::Response
- Defined in:
- lib/mushikago/http/response.rb
Overview
Mushikagoサービスのレスポンスを扱うクラス Mushikagoサービスのレスポンスは以下のような構造になっている
{ meta : { status : 200, message : 'OK' }, response : { // サービス毎に異なる情報 } }
Instance Attribute Summary (collapse)
-
- (Object) meta
readonly
レスポンスのメタ情報.
-
- (Object) response
readonly
レスポンスの本体.
Instance Method Summary (collapse)
-
- (Object) [](key)
レスポンスの各要素にアクセスする.
- - (Object) []=(key, value)
-
- (Response) initialize(options = {})
constructor
A new instance of Response.
-
- (String) message
メタ情報中のmessageを返す.
-
- (Integer) status
メタ情報中のstatusを返す.
- - (Object) to_s
Constructor Details
- (Response) initialize(options = {})
A new instance of Response
25 26 27 28 |
# File 'lib/mushikago/http/response.rb', line 25 def initialize ={} @meta = [:meta] || ['meta'] @response = [:response] || ['response'] end |
Instance Attribute Details
- (Object) meta (readonly)
レスポンスのメタ情報
18 19 20 |
# File 'lib/mushikago/http/response.rb', line 18 def @meta end |
- (Object) response (readonly)
レスポンスの本体
20 21 22 |
# File 'lib/mushikago/http/response.rb', line 20 def response @response end |
Instance Method Details
- (Object) [](key)
レスポンスの各要素にアクセスする
45 46 47 |
# File 'lib/mushikago/http/response.rb', line 45 def [] key response[key] end |
- (Object) []=(key, value)
49 50 51 |
# File 'lib/mushikago/http/response.rb', line 49 def []= key, value response[key] = value end |
- (String) message
メタ情報中のmessageを返す
38 39 40 |
# File 'lib/mushikago/http/response.rb', line 38 def [:message] end |
- (Integer) status
メタ情報中のstatusを返す
32 33 34 |
# File 'lib/mushikago/http/response.rb', line 32 def status [:status].to_i end |
- (Object) to_s
53 54 55 56 57 58 |
# File 'lib/mushikago/http/response.rb', line 53 def to_s { '@meta' => , '@response' => response }.to_json end |