lib/powertrack/streaming/stream.rb
def parse_json_body(body, &block)
      body = (body || '').strip
      begin
        body == '' ? nil : MultiJson.load(body)
      rescue
        if block_given?
          yield($!)
        else
          body
        end
      end
    end
# Parses a JSON-formatted body received as the response of a PowerTrack API
# request.
#
# Returns nil when the body is empty, the Ruby object decoded from the
# JSON-formatted body otherwise.
#
# If the parsing fails, returns the value returned by the given block which
# is called with the textual body as a single argument. If no block id,
# return the textual body initially received.
Parses a JSON-formatted body received as the response of a PowerTrack API
request.

Returns nil when the body is empty, the Ruby object decoded from the
JSON-formatted body otherwise.

If the parsing fails, returns the value returned by the given block which
is called with the textual body as a single argument. If no block id,
return the textual body initially received.
Parses a JSON - formatted body received as the response of a PowerTrack API request . Returns nil when the body is empty the Ruby object decoded from the JSON - formatted body otherwise . If the parsing fails returns the value returned by the given block which is called with the textual body as a single argument . If no block id return the textual body initially received .
def parse_json_body(body, &block)
      body = (body || '').strip
      begin
        body == '' ? nil : MultiJson.load(body)
      rescue
        if block_given?
          yield($!)
        else
          body
        end
      end
    end
def parse_json_body ( body , & block ) body = ( body || '' ) . strip begin body == '' ? nil : MultiJson . load ( body ) rescue if block_given? yield ( $! ) else body end end end
Parses a JSON-formatted body received as the response of a PowerTrack API
request.
Parses a JSON - formatted body received as the response of a PowerTrack API request .
body
block