class GramV1Client::JsonFormatter

Attributes

collection_name[R]

Public Class Methods

new(collection_name) click to toggle source
# File lib/gram_v1_client/json_formater.rb, line 8
def initialize(collection_name)
  @collection_name = collection_name.to_s
end

Public Instance Methods

decode(json) click to toggle source
# File lib/gram_v1_client/json_formater.rb, line 12
def decode(json)
  remove_root(ActiveSupport::JSON.decode(json))
end

Private Instance Methods

remove_root(data) click to toggle source
# File lib/gram_v1_client/json_formater.rb, line 18
def remove_root(data)
  if data.is_a?(Hash) && data[collection_name]
    data[collection_name]
  else
    data.first
  end
end