16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/plumb/type_registry.rb', line 16
def included(host)
host.extend TypeRegistry
constants(false).each do |const_name|
const = const_get(const_name)
anc = [host.name, const_name].join('::')
case const
when Module
next if const.is_a?(Class)
child_mod = Module.new
child_mod.define_singleton_method(:name) do
anc
end
child_mod.send(:include, const)
host.const_set(const_name, child_mod)
when Composable
type = const.dup
type.freeze.name.set(anc)
host.const_set(const_name, type)
end
end
end
|