26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/deep_cover/node/mixin/has_child_handler.rb', line 26
def has_child_handler(template)
child_method_name = format(template, name: 'child')
action = template.gsub(/_%{name}/, '').gsub(/%{name}_/, '')
const_name = "#{Tools.camelize(action)}Handler"
class_eval " module \#{const_name} # module RewriteHandler\n module ClassMethods # module ClassMethods\n def has_child(\#{action}: nil, **args) # def has_child(rewrite: nil, **args)\n name, _types = args.first # name, _types = args.first\n define_child_handler(\#{template.inspect}, # define_child_handler('rewrite_%{child}',\n name, \#{action}) # name, rewrite)\n super(**args) # super(**args)\n end # end\n end # end\n\n def \#{child_method_name}(child, name = nil) # def rewrite_child(child, name = nil)\n call_child_handler(\#{template.inspect}, child, # call_child_handler('rewrite_%{child}', child,\n name) || super # name) || super\n end # end\n end # end\n include \#{const_name} # include RewriteHandler\n singleton_class.prepend \#{const_name}::ClassMethods # singleton_class.prepend RewriteHandler::ClassMethods\n EVAL\nend\n", __FILE__, __LINE__ + 1
|