class TingYun::Support::Serialize::Marshaller

Public Class Methods

human_readable?() click to toggle source
# File lib/ting_yun/support/serialize/marshaller.rb, line 27
def self.human_readable?
  false
end

Public Instance Methods

default_encoder() click to toggle source
# File lib/ting_yun/support/serialize/marshaller.rb, line 23
def default_encoder
  Encoders::Identity
end
prepare(data, options={}) click to toggle source
# File lib/ting_yun/support/serialize/marshaller.rb, line 10
def prepare(data, options={})
  encoder = options[:encoder] || default_encoder
  if data.respond_to?(:to_collector_array)
    data.to_collector_array(encoder)
  elsif data.kind_of?(Array)
    data.map { |element| prepare(element, options) }
  elsif data.kind_of?(Hash)
    data.each {|_k,_v| data[_k]=prepare(_v, options)}
  else
    data
  end
end
return_value_for_testing(data) click to toggle source
# File lib/ting_yun/support/serialize/marshaller.rb, line 31
def return_value_for_testing(data)
  return_value(data)
end

Protected Instance Methods

return_value(data) click to toggle source
# File lib/ting_yun/support/serialize/marshaller.rb, line 37
def return_value(data)
  if data.respond_to?(:has_key?) && data.has_key?('status') 
    if data['status'] =="error"
      raise TingYun::Support::Exception::UnKnownServerException.new("sorry,the application is unable to use the tingyun service now, we should reconnect again ")
    else
      return data['result']
    end
  else
    raise TingYun::Support::Exception::UnKnownServerException.new("sorry,the application is unable to use the tingyun service now, we should reconnect again ")
  end
end