Sha256: 884549a6f10b8d8f878cc7c7774f617e1ea1cdb9a1e75017461bd9f5eb5fd761

Contents?: true

Size: 409 Bytes

Versions: 5

Compression:

Stored size: 409 Bytes

Contents

# This contains common factory methods.

module Factory
  # Given a class name as a string, create an instance of that class
  # and initialize it with the given arguments.
  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
staugaard-cloudmaster-0.1.1 lib/factory.rb
staugaard-cloudmaster-0.1.2 lib/factory.rb
staugaard-cloudmaster-0.1.3 lib/factory.rb
staugaard-cloudmaster-0.1.4 lib/factory.rb
staugaard-cloudmaster-0.1.5 lib/factory.rb