A response wrapper for CloudKit::Store
Included modules
Attributes
content | [R] | |
meta | [R] | |
status | [R] |
Public class methods
Create an instance of a Response.
# File lib/cloudkit/store/response.rb, line 10 10: def initialize(status, meta, content='') 11: @status = status; @meta = meta; @content = content 12: end
Public instance methods
Return the header value specified by key.
# File lib/cloudkit/store/response.rb, line 15 15: def [](key) 16: meta[key] 17: end
Set the header specified by key to value.
# File lib/cloudkit/store/response.rb, line 20 20: def []=(key, value) 21: meta[key] = value 22: end
Clear only the content of the response. Useful for HEAD requests.
# File lib/cloudkit/store/response.rb, line 36 36: def clear_content 37: @content = '' 38: end
Return the ETag for this response without the surrounding quotes.
# File lib/cloudkit/store/response.rb, line 48 48: def etag 49: unquote(meta['ETag']) 50: end
Return a response suitable for HEAD requests.
# File lib/cloudkit/store/response.rb, line 41 41: def head 42: response = self.dup 43: response.clear_content 44: response 45: end
Parse and return the JSON content
# File lib/cloudkit/store/response.rb, line 31 31: def parsed_content 32: JSON.parse(content) 33: end
Translate to the standard Rack representation: [status, headers, content]
# File lib/cloudkit/store/response.rb, line 25 25: def to_rack 26: meta['Content-Length'] = content.length.to_s 27: [status, meta, [content.to_s]] 28: end