Sha256: 4cfa4f162012384a5efe12375a163da386eeb41f2e9c213a38efc28e22db2fe6
Contents?: true
Size: 769 Bytes
Versions: 10
Compression:
Stored size: 769 Bytes
Contents
module RedboothRuby module Request # Wraps the API response parsing the json body and keeping interesting headers # class Response attr_accessor :body, :headers, :data, :status def initialize(attrs={}) @body = attrs[:body] @headers = attrs[:headers] @status = attrs[:status] initialize_data end protected # initializes the json data with the request body # or empty array if not def initialize_data @data = parse_body || {} end # Parses the json body if is a json valid string # def parse_body return unless body.is_a?(String) JSON.parse(body) rescue # not a valid json body nil end end end end
Version data entries
10 entries across 10 versions & 1 rubygems