turbo-rails 2.0.8 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4727e6617dc1c23ff57cb213e98eb3fd3aa11a364451d10622034c9514cb658a
4
- data.tar.gz: d20337dc3363beb18a4c5ef1b57cef22643ba2d654294daa84ce7a447645dc55
3
+ metadata.gz: 94572dc49b27a9dd77578b4bb4083732609943d5b9f850331fba2eab3fae1b8c
4
+ data.tar.gz: 6a18b6efad308fe32226a7db8e18e03df9125dcddc447b98fcbffb1ddd334697
5
5
  SHA512:
6
- metadata.gz: 32987a0bdfce8ac6a2050e7190293f5eddabf9e6349b9d228a557153d27adda86d760dcdf4fdcd3ccc00a8fd8ccb9ed945101898d6c4636cba8289835ea89ed1
7
- data.tar.gz: c5382c8d5504679799bdb22c30b73b0f057ac4c1ab818d386a23da0925e2f743f4c5f630fc33c6c9795394ef0f4fef199d661343cc1664e2156edc081ee885b0
6
+ metadata.gz: 693a6e202e6b831141985389536f23b93a2c019e96e7de54f050407fd6f25a4082a13ba0c4a3fce3e747ae895a9d0ad5851ba0cbc68acf5c254c4a57b6dd6b36
7
+ data.tar.gz: 1ee3bcbd690330b8c602532151eacc86cdb9d442649638189daa887432183df027d3a054d4c999aeb59a6aae4de5164e9fa00fa5b62e0848874ddc95878df938
@@ -6,7 +6,7 @@ module Turbo::Streams::Broadcasts
6
6
  include Turbo::Streams::ActionHelper
7
7
 
8
8
  def broadcast_remove_to(*streamables, **opts)
9
- broadcast_action_to(*streamables, action: :remove, **opts)
9
+ broadcast_action_to(*streamables, action: :remove, render: false, **opts)
10
10
  end
11
11
 
12
12
  def broadcast_replace_to(*streamables, **opts)
@@ -38,10 +38,9 @@ module Turbo::Streams::Broadcasts
38
38
  end
39
39
 
40
40
  def broadcast_action_to(*streamables, action:, target: nil, targets: nil, attributes: {}, **rendering)
41
- broadcast_stream_to(*streamables, content: turbo_stream_action_tag(action, target: target, targets: targets, template:
42
- rendering.delete(:content) || rendering.delete(:html) || (rendering[:render] != false && rendering.any? ? render_format(:html, **rendering) : nil),
43
- **attributes
44
- ))
41
+ broadcast_stream_to *streamables, content: turbo_stream_action_tag(
42
+ action, target: target, targets: targets, template: render_broadcast_action(rendering), **attributes
43
+ )
45
44
  end
46
45
 
47
46
  def broadcast_replace_later_to(*streamables, **opts)
@@ -70,7 +69,7 @@ module Turbo::Streams::Broadcasts
70
69
 
71
70
  def broadcast_refresh_later_to(*streamables, request_id: Turbo.current_request_id, **opts)
72
71
  refresh_debouncer_for(*streamables, request_id: request_id).debounce do
73
- Turbo::Streams::BroadcastStreamJob.perform_later stream_name_from(streamables), content: turbo_stream_refresh_tag(request_id: request_id, **opts)
72
+ Turbo::Streams::BroadcastStreamJob.perform_later stream_name_from(streamables), content: turbo_stream_refresh_tag(request_id: request_id, **opts).to_str # Sidekiq requires job arguments to be valid JSON types, such as String
74
73
  end
75
74
  end
76
75
 
@@ -111,4 +110,16 @@ module Turbo::Streams::Broadcasts
111
110
  def render_format(format, **rendering)
112
111
  ApplicationController.render(formats: [ format ], **rendering)
113
112
  end
113
+
114
+ def render_broadcast_action(rendering)
115
+ content = rendering.delete(:content)
116
+ html = rendering.delete(:html)
117
+ render = rendering.delete(:render)
118
+
119
+ if render == false
120
+ nil
121
+ else
122
+ content || html || (render_format(:html, **rendering) if rendering.present?)
123
+ end
124
+ end
114
125
  end
data/lib/turbo/engine.rb CHANGED
@@ -92,8 +92,8 @@ module Turbo
92
92
  end
93
93
 
94
94
  initializer "turbo.broadcastable" do
95
- ActiveSupport.on_load(:active_job) do
96
- ActiveSupport.on_load(:active_record) do
95
+ ActiveSupport.on_load(:active_record) do
96
+ if defined?(ActiveJob)
97
97
  include Turbo::Broadcastable
98
98
  end
99
99
  end
@@ -123,9 +123,9 @@ module Turbo
123
123
  include Turbo::TestAssertions
124
124
  end
125
125
 
126
- ActiveSupport.on_load(:active_job) do
127
- ActiveSupport.on_load(:action_cable) do
128
- ActiveSupport.on_load(:active_support_test_case) do
126
+ ActiveSupport.on_load(:action_cable) do
127
+ ActiveSupport.on_load(:active_support_test_case) do
128
+ if defined?(ActiveJob)
129
129
  require "turbo/broadcastable/test_helper"
130
130
  include Turbo::Broadcastable::TestHelper
131
131
  end
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-09-18 00:00:00.000000000 Z
13
+ date: 2024-09-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.5.11
113
+ rubygems_version: 3.5.16
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: The speed of a single-page web application without having to write any JavaScript.