Class: Kestrel::Client::Unmarshal

Inherits:
Proxy
  • Object
show all
Defined in:
lib/kestrel/client/unmarshal.rb

Instance Attribute Summary

Attributes inherited from Proxy

#client

Instance Method Summary collapse

Methods inherited from Proxy

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Kestrel::Client::Proxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Kestrel::Client::Proxy

Instance Method Details

#get(keys, raw = false) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/kestrel/client/unmarshal.rb', line 4

def get(keys, raw = false)
  response = client.get(keys, true)
  return response if raw
  if is_marshaled?(response)
    Marshal.load_with_constantize(response, loaded_constants = [])
  else
    response
  end
end

#is_marshaled?(object) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/kestrel/client/unmarshal.rb', line 14

def is_marshaled?(object)
  object.to_s[0] == Marshal::MAJOR_VERSION && object.to_s[1] == Marshal::MINOR_VERSION
rescue Exception
  false
end