rooibos 0.7.1 → 0.7.3

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: 90779a1947e5b95b3fadc6917fb2254408ec8361c4995782e01a91019d386628
4
- data.tar.gz: 50dab255aa26895d8d1cc5bd7b31b14a7cce4c1d052108f5c4010037dfe4c917
3
+ metadata.gz: 62b5746b5691433de9604aed2deb6e083f5af45510123545831ad594b9b5c3da
4
+ data.tar.gz: 8d007372dd8abf556f83b1ab40d70139cc2c407d22f317b550bfc760b8d7080d
5
5
  SHA512:
6
- metadata.gz: e9b7ef36e9e9095ba819bf36a10715a1a5d8a12ca96104eadc683d4fb7247702bc5d2ac069e67da103e06d72c3e6d6d8224b86dd6576a7fcef65e2e802bda2b6
7
- data.tar.gz: 6c104e16082e4c548ef28b9022942e30eb9bd9cc40861ac6fe906712f0c059966438e18c6adaccd6874081770033a65609423f9d4898961135fa1621a25cce4c
6
+ metadata.gz: 447fa181daa6eb2fff6470154bbb2a4ee94ec3fb8a2876b2a9a52e8093d098257c87e5c464fbcee87aace83d0323fa0aba7fc0961220c10f1230d62c051fd0b5
7
+ data.tar.gz: e654c9118df85fd0332a4b6664de6d359d7ff0dfc241415abee1508584d7b9f95d8f4dcf1f25c8ee71b5f492ac796e2355c0f319e4d24abc28599b3f7588f92b
@@ -32,10 +32,16 @@ module Rooibos
32
32
  new(callable: apply_scope(normalized))
33
33
  end
34
34
 
35
+ # Combines two guards into a single callable without creating a closure.
36
+ class CombinedGuard < Data.define(:inner, :outer)
37
+ def arity = 2
38
+ def call(msg, model) = inner.call(msg, model) && outer.call(msg, model)
39
+ end
40
+
35
41
  private_class_method def self.apply_scope(callable)
36
42
  @scope.inject(callable) do |inner, outer|
37
43
  if inner
38
- -> (msg, model) { outer.call(msg, model) && inner.call(msg, model) }
44
+ CombinedGuard.new(inner:, outer:)
39
45
  else
40
46
  outer
41
47
  end
@@ -165,22 +165,6 @@ module Rooibos
165
165
  routes.add(Route.new(prefix: prefix&.to_s&.to_sym, fragment: to, read:, write:))
166
166
  end
167
167
 
168
- # Forwards all instances of a class to routes.
169
- #
170
- # Matches messages by class. Ideal for custom message types or
171
- # RatatuiRuby event classes like <tt>Event::Resize</tt>.
172
- #
173
- # Use <tt>broadcast: true</tt> to send to all declared routes, or
174
- # <tt>broadcast_to:</tt> with an array of specific route targets.
175
- #
176
- # === Example
177
- #
178
- # forward_instances_of RatatuiRuby::Event::Resize, to: :main_layout
179
- # forward_instances_of ThemeChanged, broadcast: true
180
- def forward_instances_of(klass, ...)
181
- forwards.add_instances_of(klass, ...)
182
- end
183
-
184
168
  # Defines a named action referenceable by symbol.
185
169
  #
186
170
  # Actions are reusable handlers. Reference them by name in
@@ -322,6 +306,22 @@ module Rooibos
322
306
  forwards.add_events(keys, to:, **)
323
307
  end
324
308
 
309
+ # Forwards all instances of a class to routes.
310
+ #
311
+ # Matches messages by class. Ideal for custom message types or
312
+ # RatatuiRuby event classes like <tt>Event::Resize</tt>.
313
+ #
314
+ # Use <tt>broadcast: true</tt> to send to all declared routes, or
315
+ # <tt>broadcast_to:</tt> with an array of specific route targets.
316
+ #
317
+ # === Example
318
+ #
319
+ # forward_instances_of RatatuiRuby::Event::Resize, to: :main_layout
320
+ # forward_instances_of ThemeChanged, broadcast: true
321
+ def forward_instances_of(klass, to: @_scoped_target, **)
322
+ forwards.add_instances_of(klass, to:, **)
323
+ end
324
+
325
325
  # Routes matching routed messages to a declared route.
326
326
  #
327
327
  # Matches <tt>Message::Routed</tt> messages by envelope. Use this
@@ -8,5 +8,5 @@
8
8
  module Rooibos
9
9
  # The version of this gem.
10
10
  # See https://semver.org/spec/v2.0.0.html
11
- VERSION = "0.7.1"
11
+ VERSION = "0.7.3"
12
12
  end
@@ -16,6 +16,14 @@ module Rooibos
16
16
 
17
17
  # Evaluates the guard. Returns true if no callable.
18
18
  def call: (message, _DataModel) -> boolish
19
+
20
+ class CombinedGuard < Data
21
+ attr_reader inner: guard
22
+ attr_reader outer: guard
23
+
24
+ def arity: () -> Integer
25
+ def call: (message, _DataModel) -> boolish
26
+ end
19
27
  end
20
28
  end
21
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rooibos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kerrick Long