Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/test_benchmarker/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#to_classObject

similar to ActiveSupports constantize, but doesn’t require the use of active support.



10
11
12
13
14
15
16
# File 'lib/test_benchmarker/core_ext.rb', line 10

def to_class
  ObjectSpace.each_object(Class) do |klass|
    return klass if klass.to_s == self
  end
  
  raise TestBenchmarker::ClassNotFoundError.new(self), "A class matching '#{self}' could not be found"
end