Class: Specinfra::CommandFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/specinfra/command_factory.rb

Constant Summary collapse

@@types =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(os_info) ⇒ CommandFactory

Returns a new instance of CommandFactory


8
9
10
# File 'lib/specinfra/command_factory.rb', line 8

def initialize(os_info)
  @os_info = os_info
end

Class Method Details

.instanceObject


4
5
6
# File 'lib/specinfra/command_factory.rb', line 4

def self.instance
  self.new(os)
end

Instance Method Details

#get(meth, *args) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/specinfra/command_factory.rb', line 12

def get(meth, *args)
  action, resource_type, subaction = breakdown(meth)
  method =  action
  method += "_#{subaction}" if subaction
  command_class = create_command_class(resource_type)
  if command_class.respond_to?(method)
    command_class.send(method, *args)
  else
    raise NotImplementedError.new("#{method} is not implemented in #{command_class}")
  end
end