Class: SafeConstantize

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

Defined Under Namespace

Classes: IllegalClassToConstantize

Class Method Summary collapse

Class Method Details

.constantize(class_name, allowed) ⇒ Object



4
5
6
7
# File 'lib/safe_constantize.rb', line 4

def self.constantize(class_name, allowed)
  raise IllegalClassToConstantize, "Not allowed to constantize: #{class_name}" unless allowed.include?(class_name.to_s)
  class_name.constantize
end