87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/autorequire.rb', line 87
def self.new name, parent
name = name.to_s
Module.new do
include ConstProxy
singleton_class = class << self; self; end
singleton_class.module_eval do
define_method('name'){ name }
define_method('parent'){ parent }
define_method('to_s'){ "ConstProxy(#{ name })" }
define_method('inspect'){ "\"#{ to_s }\"" }
define_method('to_const'){
if ConstProxy?(parent)
parent.to_const.const_get name else
parent.const_get name
end
}
end
end
end
|