Module: SdbService::Constantizer

Included in:
Service
Defined in:
lib/sdb_service/support/constantizer.rb

Instance Method Summary collapse

Instance Method Details

#constantize(klass_name, load_path) ⇒ Object

hackish helper method for properly casting a string to a constantized class.



5
6
7
8
# File 'lib/sdb_service/support/constantizer.rb', line 5

def constantize(klass_name, load_path)
  require "#{load_path}/#{klass_name}"
  eval(klass_name.gsub(/^[a-z]|\s|_+[a-z]/) { |a| a.upcase }.gsub(/\s|_/, '')) rescue nil
end