class Wire::Resource::ResourceFactory

ResourceFactory creates Resource objects given by symbolic name

Public Instance Methods

create(resource_symname, *resource_nameargs) click to toggle source

given a resource_symname as a symbol (i.e. :ovsbridge) this creates a resource with given name (i.e. “testbridge”) and hands on arguments (resource_nameargs, may be 1..n) returns

  • a new Resource object, depending on type

# File lib/wire/resource/resource.rb, line 38
def create(resource_symname, *resource_nameargs)
  clazz_map = {
    :ovsbridge  => OVSBridge,
    :bridgeip   => IPAddressOnIntf,
    :dhcpconfig => DHCPRangeConfiguration,
    :figadapter => FigAdapter,
    :networkinjection => NetworkInjection
  }
  clazz = clazz_map[resource_symname]
  fail(ArgumentError, "Unknown resource type #{resource_symname}") unless clazz
  clazz.new(*resource_nameargs)
end