Class: QemuToolkit::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/qemu-toolkit/config.rb

Overview

A configuration class that acts as a singleton, but really isn’t. This allows for a mixed style of coding, either using QemuToolkit::Config as an instance or as a class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#etc(*args) ⇒ Object



28
29
30
# File 'lib/qemu-toolkit/config.rb', line 28

def etc(*args)
  expand_path(@etc, *args)
end

#var_run(*args) ⇒ Object



31
32
33
# File 'lib/qemu-toolkit/config.rb', line 31

def var_run(*args)
  expand_path(@var_run, *args)
end

Class Method Details

.currentObject



17
18
19
# File 'lib/qemu-toolkit/config.rb', line 17

def current
  @current ||= new
end

.method_missing(sym, *args, &block) ⇒ Object



9
10
11
12
# File 'lib/qemu-toolkit/config.rb', line 9

def method_missing(sym, *args, &block)
  return current.send(sym, *args, &block) if current.respond_to?(sym)
  super
end

.resetObject



20
21
22
# File 'lib/qemu-toolkit/config.rb', line 20

def reset 
  @current = nil
end

.respond_to?(sym) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/qemu-toolkit/config.rb', line 13

def respond_to?(sym)
  current.respond_to?(sym) || super
end

Instance Method Details

#backendObject

The command runner backend for all commands. Actual execution happens through this instance. This has advantages for testing and for customizing behaviour.



39
40
41
# File 'lib/qemu-toolkit/config.rb', line 39

def backend
  @backend ||= Backend::Illumos.new
end