Class: Kestrel::Client::Unmarshal
- Defined in:
- lib/kestrel/client/unmarshal.rb
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
Methods inherited from Proxy
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(key, opts = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/kestrel/client/unmarshal.rb', line 4 def get(key, opts = {}) response = client.get(key, opts.merge(:raw => true)) return response if opts[:raw] if is_marshaled?(response) Marshal.load_with_constantize(response, loaded_constants = []) else response end end |
#is_marshaled?(object) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/kestrel/client/unmarshal.rb', line 16 def is_marshaled?(object) o = object.to_s o.getbyte(0) == Marshal::MAJOR_VERSION && o.getbyte(1) == Marshal::MINOR_VERSION rescue Exception false end |