Module: Factory

Included in:
LoggerFactory
Defined in:
lib/factory.rb

Overview

This contains common factory methods.

Class Method Summary collapse

Class Method Details

.create_object_from_string(class_name, *args) ⇒ Object

Given a class name as a string, create an instance of that class and initialize it with the given arguments.



6
7
8
9
10
11
12
13
# File 'lib/factory.rb', line 6

def Factory.create_object_from_string(class_name, *args)
  ObjectSpace.each_object(Class) do |x|
    if x.name == class_name || x.name == "Cloudmaster::#{class_name}"
      return x.new(*args)
    end
  end
  nil
end