Class: Kestrel::Client::Envelope

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

Instance Attribute Summary collapse

Attributes inherited from Proxy

#client

Instance Method Summary collapse

Methods inherited from Proxy

#method_missing

Constructor Details

#initialize(envelope_class, client) ⇒ Envelope

Returns a new instance of Envelope.



6
7
8
9
# File 'lib/kestrel/client/envelope.rb', line 6

def initialize(envelope_class, client)
  @envelope_class = envelope_class
  super(client)
end

Dynamic Method Handling

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

Instance Attribute Details

#envelope_classObject

Returns the value of attribute envelope_class.



4
5
6
# File 'lib/kestrel/client/envelope.rb', line 4

def envelope_class
  @envelope_class
end

Instance Method Details

#get(*args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/kestrel/client/envelope.rb', line 11

def get(*args)
  response = client.get(*args)
  if response.respond_to?(:unwrap)
    response.unwrap
  else
    response
  end
end

#set(key, value, *args) ⇒ Object



20
21
22
# File 'lib/kestrel/client/envelope.rb', line 20

def set(key, value, *args)
  client.set(key, envelope_class.new(value), *args)
end