Class: Rprov::Decorator

Inherits:
Object
  • Object
show all
Defined in:
lib/rprov/decorator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component) ⇒ Decorator

Returns a new instance of Decorator.



5
6
7
# File 'lib/rprov/decorator.rb', line 5

def initialize(component)
  @component = component
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



3
4
5
# File 'lib/rprov/decorator.rb', line 3

def component
  @component
end

Instance Method Details

#info(path) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/rprov/decorator.rb', line 45

def info(path)
  begin
    component.info(path)
  rescue Rprov::Missing
    fail_missing(path)
  end
end

#setup(path) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rprov/decorator.rb', line 33

def setup(path)
  init("Setting up Redis Instance: #{path}")

  begin
    component.setup(path)
  rescue Rprov::Conflict
    fail("The path #{path} already exists.")
  else
    say("Done!")
  end
end

#start(path) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/rprov/decorator.rb', line 9

def start(path)
  init("Starting Redis Instance: `#{path}`")

  begin
    component.start(path)
  rescue Rprov::Missing
    fail_missing(path)
  end
end

#stop(path) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rprov/decorator.rb', line 19

def stop(path)
  init("Stopping Redis Instance: `#{path}`")

  begin
    component.stop(path)
  rescue Errno::ECONNREFUSED
    fail("The instance appears to be down.")
  rescue Rprov::Missing
    fail_missing(path)
  else
    say("Done!")
  end
end