Class: Kestrel::Client::Namespace

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

Instance Attribute Summary

Attributes inherited from Proxy

#client

Instance Method Summary collapse

Methods inherited from Proxy

#method_missing

Constructor Details

#initialize(namespace, client) ⇒ Namespace

Returns a new instance of Namespace.



4
5
6
7
8
# File 'lib/kestrel/client/namespace.rb', line 4

def initialize(namespace, client)
  @namespace = namespace
  @matcher = /\A#{Regexp.escape(@namespace)}:(.+)/
  super(client)
end

Dynamic Method Handling

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

Instance Method Details

#available_queuesObject



14
15
16
# File 'lib/kestrel/client/namespace.rb', line 14

def available_queues
  client.available_queues.map {|q| in_namespace(q) }.compact
end

#in_namespace(key) ⇒ Object



18
19
20
21
22
# File 'lib/kestrel/client/namespace.rb', line 18

def in_namespace(key)
  if match = @matcher.match(key)
    match[1]
  end
end

#namespace(key) ⇒ Object



24
25
26
# File 'lib/kestrel/client/namespace.rb', line 24

def namespace(key)
  "#{@namespace}:#{key}"
end