ruflet_core 0.0.20 → 0.0.21
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96131a85e131d05e9d2bbe07eb2bb3ceba97aeb2112301d4d6137d7067e81c3c
|
|
4
|
+
data.tar.gz: 21245edeb2dc44b0cfe457c34678a552929ef813b2309494453582b717558209
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1889c987529cb0915da64b09e534d8d132c34c1ec1553d099f3a81340744d57a5a48a8325ae77f6a4b19f7537440dae1a6c77a5dc7d632548b7dfe297de857f7
|
|
7
|
+
data.tar.gz: ce99b6ffcae8ccc7c6837df5f53fe936bd1df521c73642a60957a3552a53500b5626a2d0611d571cc069efca0c597194ff4ec627916b73d07081e6046cf96611
|
data/lib/ruflet/version.rb
CHANGED
|
@@ -37,6 +37,26 @@ module Ruflet
|
|
|
37
37
|
]
|
|
38
38
|
}.freeze
|
|
39
39
|
|
|
40
|
+
# Whether a name resolves to a control, including extensions registered at
|
|
41
|
+
# runtime. Used to decide when a missing method is a DSL call rather than
|
|
42
|
+
# something Ruby expected to raise.
|
|
43
|
+
def known_control?(name)
|
|
44
|
+
key = name.to_s.downcase
|
|
45
|
+
EXTENSION_CLASS_MAP.key?(key) || CLASS_MAP.key?(key)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Where an unregistered extension helper is still meant to build a
|
|
49
|
+
# control: a script's top level, and objects the framework owns. Anything
|
|
50
|
+
# else asking for an unknown method is asking by accident.
|
|
51
|
+
def dsl_receiver?(receiver)
|
|
52
|
+
return true if receiver.equal?(TOPLEVEL_BINDING.receiver)
|
|
53
|
+
|
|
54
|
+
name = receiver.class.name
|
|
55
|
+
name.is_a?(String) && name.start_with?("Ruflet::")
|
|
56
|
+
rescue StandardError
|
|
57
|
+
false
|
|
58
|
+
end
|
|
59
|
+
|
|
40
60
|
def build(type, id: nil, **props)
|
|
41
61
|
normalized_type = type.to_s.downcase
|
|
42
62
|
if ENV["RUFLET_DEBUG"] == "1" && normalized_type == "floatingactionbutton"
|
|
@@ -338,8 +338,13 @@ module Ruflet
|
|
|
338
338
|
# module. Unknown widget-style helpers with properties are forwarded as
|
|
339
339
|
# generic controls, allowing locally installed extensions to participate
|
|
340
340
|
# in the same Ruby DSL without VM or application-specific methods.
|
|
341
|
+
# See Kernel#method_missing: this module is included into Kernel, so it
|
|
342
|
+
# must decline the same calls Ruby expects to raise on.
|
|
341
343
|
def method_missing(name, *args, **props, &block)
|
|
342
344
|
return super if name.to_s.end_with?("=") || (args.empty? && props.empty? && !block)
|
|
345
|
+
unless Ruflet::UI::ControlFactory.known_control?(name) || Ruflet::UI::ControlFactory.dsl_receiver?(self)
|
|
346
|
+
return super
|
|
347
|
+
end
|
|
343
348
|
|
|
344
349
|
forwarded = props.dup
|
|
345
350
|
forwarded[:value] = args.shift unless args.empty?
|
data/lib/ruflet_ui.rb
CHANGED
|
@@ -169,8 +169,20 @@ module Kernel
|
|
|
169
169
|
Ruflet::DSL
|
|
170
170
|
end
|
|
171
171
|
|
|
172
|
+
# This is Kernel, so it sees every missing method in the process, including
|
|
173
|
+
# ones Ruby itself calls speculatively and expects to raise. Fabricating a
|
|
174
|
+
# control for those hands internals an object of the wrong type — a
|
|
175
|
+
# Process::Waiter receiving one fails with "wrong argument type
|
|
176
|
+
# Ruflet::Control (expected Process::Status)".
|
|
177
|
+
#
|
|
178
|
+
# Only build a control for a name the framework actually knows, or for calls
|
|
179
|
+
# written at the top level of a script, where an unregistered extension
|
|
180
|
+
# helper is still expected to work.
|
|
172
181
|
def method_missing(name, *args, **props, &block)
|
|
173
182
|
return super if name.to_s.end_with?("=") || (args.empty? && props.empty? && !block)
|
|
183
|
+
unless Ruflet::UI::ControlFactory.known_control?(name) || Ruflet::UI::ControlFactory.dsl_receiver?(self)
|
|
184
|
+
return super
|
|
185
|
+
end
|
|
174
186
|
|
|
175
187
|
forwarded = props.dup
|
|
176
188
|
forwarded[:value] = args.shift unless args.empty?
|