Class: Cloudflare::Message
- Inherits:
-
Object
- Object
- Cloudflare::Message
- Defined in:
- lib/cloudflare/representation.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #errors ⇒ Object
- #headers ⇒ Object
-
#initialize(response) ⇒ Message
constructor
A new instance of Message.
- #messages ⇒ Object
- #read ⇒ Object
- #result ⇒ Object
- #results ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Message
Returns a new instance of Message.
40 41 42 43 44 45 46 |
# File 'lib/cloudflare/representation.rb', line 40 def initialize(response) @response = response @body = response.read # Some endpoints return the value instead of a message object (like KV reads) @body = { success: true, result: @body } unless @body.is_a?(Hash) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
49 50 51 |
# File 'lib/cloudflare/representation.rb', line 49 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
48 49 50 |
# File 'lib/cloudflare/representation.rb', line 48 def response @response end |
Instance Method Details
#errors ⇒ Object
67 68 69 |
# File 'lib/cloudflare/representation.rb', line 67 def errors @body[:errors] end |
#headers ⇒ Object
51 52 53 |
# File 'lib/cloudflare/representation.rb', line 51 def headers @response.headers end |
#messages ⇒ Object
71 72 73 |
# File 'lib/cloudflare/representation.rb', line 71 def @body[:messages] end |
#read ⇒ Object
59 60 61 |
# File 'lib/cloudflare/representation.rb', line 59 def read @body[:result] end |
#result ⇒ Object
55 56 57 |
# File 'lib/cloudflare/representation.rb', line 55 def result @body[:result] end |
#results ⇒ Object
63 64 65 |
# File 'lib/cloudflare/representation.rb', line 63 def results Array(result) end |
#success? ⇒ Boolean
75 76 77 |
# File 'lib/cloudflare/representation.rb', line 75 def success? @body[:success] end |