view_component_devtools 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/view_component_devtools/component.rb +14 -37
- data/lib/view_component_devtools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2af7b0e20aeaa0d3d3e75c5255b567050c2425b73d95819c539eff4ea289bfaf
|
|
4
|
+
data.tar.gz: 7653f7e096b59b3629a591610e814917c55d8ebac86a760993eb204fe61e1714
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d05d4d3bc6e21473251b807f4680ce8a551c5d9de5bc195f37be2e730aaea7b19598ced8b9b948f5a1637ab108fb7818b869b82b9a06ffd6ecf83281649818ab
|
|
7
|
+
data.tar.gz: 309af696584ad38c6bed98e5210707c480401f355e66ece9f4183e88ba5555f65542bea0d77ea556384f548a6a51cf833adf72517d397747a0d4b1e706763b87
|
|
@@ -13,54 +13,33 @@ module ViewComponentDevtools
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def view_component_devtools_prop_names
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
inferred = classes.flat_map do |component_class|
|
|
21
|
-
component_initializer(component_class)&.parameters&.filter_map do |kind, name|
|
|
22
|
-
name if %i[req opt keyreq key].include?(kind)
|
|
23
|
-
end || []
|
|
24
|
-
end
|
|
16
|
+
declared = @view_component_devtools_props || []
|
|
17
|
+
inferred = component_initializer&.parameters&.filter_map do |kind, name|
|
|
18
|
+
name if %i[req opt keyreq key].include?(kind)
|
|
19
|
+
end || []
|
|
25
20
|
|
|
26
21
|
(declared + inferred).uniq.select do |name|
|
|
27
|
-
|
|
22
|
+
directly_defined_reader?(name)
|
|
28
23
|
end
|
|
29
24
|
end
|
|
30
25
|
|
|
31
26
|
private
|
|
32
27
|
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
component_class = self
|
|
38
|
-
|
|
39
|
-
while component_class.is_a?(Class) && component_class != boundary
|
|
40
|
-
classes << component_class
|
|
41
|
-
component_class = component_class.superclass
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
classes
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def component_initializer(component_class)
|
|
48
|
-
return unless component_class.private_instance_methods(false).include?(:initialize) ||
|
|
49
|
-
component_class.protected_instance_methods(false).include?(:initialize) ||
|
|
50
|
-
component_class.public_instance_methods(false).include?(:initialize)
|
|
28
|
+
def component_initializer
|
|
29
|
+
return unless private_instance_methods(false).include?(:initialize) ||
|
|
30
|
+
protected_instance_methods(false).include?(:initialize) ||
|
|
31
|
+
public_instance_methods(false).include?(:initialize)
|
|
51
32
|
|
|
52
|
-
|
|
53
|
-
initializer if initializer.owner == component_class
|
|
33
|
+
instance_method(:initialize)
|
|
54
34
|
end
|
|
55
35
|
|
|
56
|
-
def
|
|
57
|
-
return false unless
|
|
36
|
+
def directly_defined_reader?(name)
|
|
37
|
+
return false unless public_instance_methods(false).include?(name)
|
|
58
38
|
|
|
59
39
|
method = instance_method(name)
|
|
60
|
-
|
|
40
|
+
method.parameters.none? do |kind, _|
|
|
61
41
|
%i[req keyreq].include?(kind)
|
|
62
42
|
end
|
|
63
|
-
callable_without_arguments && (explicitly_declared || classes.include?(method.owner))
|
|
64
43
|
end
|
|
65
44
|
end
|
|
66
45
|
|
|
@@ -86,9 +65,7 @@ module ViewComponentDevtools
|
|
|
86
65
|
return identifier if identifier
|
|
87
66
|
end
|
|
88
67
|
|
|
89
|
-
initializer = self.class.send(:
|
|
90
|
-
self.class.send(:component_initializer, component_class)
|
|
91
|
-
end.first
|
|
68
|
+
initializer = self.class.send(:component_initializer)
|
|
92
69
|
initializer&.source_location&.join(":")
|
|
93
70
|
end
|
|
94
71
|
end
|