Method: Object#make_module
- Defined in:
- lib/garcon/core_ext/object.rb
#make_module(string) ⇒ nil
Defines module from a string name (e.g. Foo::Bar::Baz). If module already exists, no exception raised.
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/garcon/core_ext/object.rb', line 244 def make_module(string) current_module = self string.split('::').each do |part| current_module = if current_module.const_defined?(part) current_module.const_get(part) else current_module.const_set(part, Module.new) end end current_module end |