Method: Rundock::TargetFactory#create

Defined in:
lib/rundock/target_factory.rb

#create(name, attributes) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rundock/target_factory.rb', line 13

def create(name, attributes)
  klass = "Rundock::Target::#{@type.to_s.to_camel_case}"
  Logger.debug("initialize #{klass} target")
  raise TargetNotSupportedError unless Rundock::Target::Base.subclasses.map(&:to_s).include?(klass)

  obj = nil
  klass.split('::').map do |k|
    obj = if obj.nil?
            Kernel.const_get(k)
          else
            obj = obj.const_get(k)
          end
  end

  target = obj.new(name, attributes)
  target
end