Class: Sbmt::Strangler::ConstDefiner

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/strangler/const_definer.rb

Class Method Summary collapse

Class Method Details

.call!(name, klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sbmt/strangler/const_definer.rb', line 7

def call!(name, klass)
  const_names = name.split("::")
  class_name = const_names.pop
  module_name = if const_names.any?
    define_modules(const_names)
  else
    Object
  end

  module_name.const_set(class_name, klass)
end