Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit 7d14782

Browse files
committed
Minor simplification of Object#make_module
1 parent 1f7e23d commit 7d14782

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/extlib/object.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ def full_const_set(name, value)
9595
# @param name<String> The name of the full module name to make
9696
#
9797
# @return [nil]
98-
def make_module(str)
99-
mod = str.split("::")
98+
def make_module(string)
10099
current_module = self
101-
mod.each do |x|
102-
unless current_module.const_defined?(x)
103-
current_module.class_eval "module #{x}; end", __FILE__, __LINE__
100+
string.split('::').each do |part|
101+
current_module = if current_module.const_defined?(part)
102+
current_module.const_get(part)
103+
else
104+
current_module.const_set(part, Module.new)
104105
end
105-
current_module = current_module.const_get(x)
106106
end
107107
current_module
108108
end

0 commit comments

Comments
 (0)