class RabbitMQ::HTTP::ResponseHelper

Public Class Methods

new(client) click to toggle source
# File lib/rabbitmq/http/client/response_helper.rb, line 11
def initialize(client)
  @client = client
end

Public Instance Methods

decode_resource(response) click to toggle source
# File lib/rabbitmq/http/client/response_helper.rb, line 15
def decode_resource(response)
  if response.nil? || response.body.nil? || response.body.empty?
    Hashie::Mash.new
  else
    decode_response_body(response.body)
  end
end
decode_resource_collection(response) click to toggle source
# File lib/rabbitmq/http/client/response_helper.rb, line 31
def decode_resource_collection(response)
  collection = response.body.is_a?(Array) ? response.body : response.body.fetch('items')

  collection.map do |i|
    if i == []
      Hashie::Mash.new()
    else
      Hashie::Mash.new(i)
    end
  end
end
decode_response_body(body) click to toggle source
# File lib/rabbitmq/http/client/response_helper.rb, line 23
def decode_response_body(body)
  if body.empty?
    Hashie::Mash.new
  else
    Hashie::Mash.new(body)
  end
end