23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/tapioca/dsl/compilers/phlex_controller.rb', line 23
def decorate
root.create_path(constant) do |klass|
klass. << RBI::Comment.new(
<<~DOC,
A Phlex component that wraps the `#{constant.controller_name.inspect}` Stimulus controller.
LINK: #{constant.controller_path}
DOC
)
mod = klass.create_module(MOD_NAME)
klass.create_extend(MOD_NAME)
actions = constant.action_defs.sort_by(&:action_name)
actions.each do |action|
= [
RBI::Comment.new(
<<~DOC,
Returns the identifier of `#{action.action_name}`
action on `#{action.component.controller_name.inspect}` Stimulus controller
Result: `#{action.full_name.inspect}`
DOC
),
]
mod.create_method(
action.ruby_action_method_name,
return_type: 'String',
comments: ,
)
end
targets = constant.target_defs.sort_by(&:target_name)
targets.each do |target|
= [
RBI::Comment.new(
<<~DOC,
Returns the identifier of `#{target.target_name}`
target on `#{target.component.controller_name.inspect}` Stimulus controller
Result: `#{target.target_name.inspect}`
DOC
),
]
mod.create_method(
target.ruby_target_method_name,
return_type: 'String',
comments: ,
)
end
end
end
|