Class: Andpush::JsonResponse

Inherits:
Net::HTTPResponse
  • Object
show all
Defined in:
lib/andpush/json_handler.rb

Constant Summary collapse

HAS_SYMBOL_GC =
RUBY_VERSION > '2.2.0'

Instance Method Summary collapse

Instance Method Details

#inspectObject Also known as: to_s



14
15
16
# File 'lib/andpush/json_handler.rb', line 14

def inspect
  "#<JsonResponse response: #{response.inspect}, json: #{json}>"
end

#jsonObject



10
11
12
# File 'lib/andpush/json_handler.rb', line 10

def json
  parsable? ? JSON.parse(body, symbolize_names: HAS_SYMBOL_GC) : nil
end

#parsable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/andpush/json_handler.rb', line 19

def parsable?
  !!body && !body.empty?
end