Class: Canery::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/canery/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection_uri = nil) ⇒ Client

Returns a new instance of Client.



12
13
14
# File 'lib/canery/client.rb', line 12

def initialize(connection_uri = nil)
  @backend = Backend.new(connection_uri)
end

Instance Method Details

#delete_tub(name) ⇒ Object



27
28
29
30
31
# File 'lib/canery/client.rb', line 27

def delete_tub(name)
  build_tub_name!(name)
  @tub_cache.delete(name) if @tub_cache[name]
  backend.call(:delete_namespace, name)
end

#has_tub?(name) ⇒ Boolean Also known as: tub?

Returns:

  • (Boolean)


33
34
35
# File 'lib/canery/client.rb', line 33

def has_tub?(name)
  backend.call(:namespace?, name)
end

#tub(name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/canery/client.rb', line 16

def tub(name)
  build_tub_name!(name)
  create_tub(name) unless tub?(name)
  begin
    @tub_cache ||= {}
    @tub_cache[name] ||= Tub.new(backend, name)
  rescue
    raise Canery::CaneryError, "This tub does not exist! You must create it before you can use it."
  end
end

#tubsObject



38
39
40
# File 'lib/canery/client.rb', line 38

def tubs
  backend.call(:namespaces)
end