Class: ClassLoader

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

Overview

Class loading mechanism, we use this to create new instances of objects based on config data. This allows a user to set their own config for instance to use thier own implmentation of a given class. ClassLoader based on Rails constantize

Class Method Summary collapse

Class Method Details

.load_class(class_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/esapi.rb', line 7

def self.load_class(class_name)
  # we are using ruby 1.9.2 as a requirement, so we can use the inheritance
  # of const_get to find our object. if mis-spelled it will raise a NameError
  names = class_name.split("::")
  klass = Object
  names.each do |name|
    klass = klass.const_get(name)
  end
  klass.new
end