Class: Pec::Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/pec/sample.rb,
lib/pec/configure.rb

Defined Under Namespace

Classes: Sample

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Configure

Returns a new instance of Configure.



5
6
7
8
# File 'lib/pec/configure.rb', line 5

def initialize(config)
  validate(config)
  @_config = config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



22
23
24
# File 'lib/pec/configure.rb', line 22

def method_missing(method, *args)
  @_config[1][method.to_s]
end

Instance Method Details

#inspectObject



10
11
12
# File 'lib/pec/configure.rb', line 10

def inspect
  @_config
end

#keysObject



18
19
20
# File 'lib/pec/configure.rb', line 18

def keys
  @_config[1].keys
end

#nameObject



14
15
16
# File 'lib/pec/configure.rb', line 14

def name
  @_config[0]
end

#validate(config) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/pec/configure.rb', line 26

def validate(config)
  %w(
    tenant
    image
    flavor
    networks
  ).each do |k|
    raise "#{config[0]}:host key #{k} is require" unless config[1][k]
  end
end