reactive_component 0.6.2 → 0.7.0

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: b0c408bc69906500eee92927b43eb4f307039d4faab5e6fda80b5461ba922db0
4
- data.tar.gz: 6ccf997e199cdd409138b48b187199b55c625dcdb165aabb808c2ed0657a23f6
3
+ metadata.gz: 4a63e206cf0f143eb6c390357606b7de7bd67d8c516867883d3c125b865ff664
4
+ data.tar.gz: ab1e03efda80cff6207b6e7828bc42cdd23cf207953f803a620ccea143719a6c
5
5
  SHA512:
6
- metadata.gz: 689c1ffeab1b2b2c93b7df69765a9a0660c9cd5c215704b63cd5ac9128d152ac34bd39b0f8934b2798e37a649b3d6b2486aad3cf97d977f0cf3c374885f42a92
7
- data.tar.gz: 6596df41e9f41b447e9e8365c5f7c1fd8603fca4212eb2f15e429278a78e65c09c929edf753d353f1f65311533c9018bdcb4236aadf0d47a97a4964cdbb6af71
6
+ metadata.gz: 2476e8ed1dcef187d6abfe7b011cbb8e076ac41ac0cd266b48f4174ec1c4f503ba618d8eb104c19d288f18d694a74d57e2fa2c0e591ded079113d99dc166ee7f
7
+ data.tar.gz: 5f6aae9647f439578c0585d3ba66586c60442a75003531c9a98e8ce0f267c77fd3089830ce9d5c17f3c91638ffd5b3c13f4ba7533d638f4c7d90da92d80f43b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0] - 2026-09-06
4
+
5
+ ### Fixed
6
+ - `live_action` params are filtered with `permit` against the declared
7
+ list, so a nested hash or array sent for a scalar param no longer reaches
8
+ the action method.
9
+
10
+ ### Added
11
+ - `live_action` `params:` accepts the full `permit` spec, so an action can
12
+ declare arrays and nested hashes: `params: [:title, { tags: [] }]`.
13
+
3
14
  ## [0.6.2] - 2026-09-06
4
15
 
5
16
  ### Changed
@@ -10,7 +10,7 @@ module ReactiveComponent
10
10
  component_class.execute_action(
11
11
  params[:action_name],
12
12
  record,
13
- params.fetch(:params, {}).permit!.to_h
13
+ params.fetch(:params, {})
14
14
  )
15
15
 
16
16
  head :ok
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactiveComponent
4
- VERSION = '0.6.2'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -192,9 +192,12 @@ module ReactiveComponent
192
192
  end
193
193
  end
194
194
 
195
+ # `params:` takes the same spec as `ActionController::Parameters#permit`:
196
+ # live_action :move, params: [:label_id]
197
+ # live_action :save, params: [:title, { tags: [], address: [:city] }]
195
198
  def live_action(action_name, params: [])
196
199
  self._live_actions = _live_actions.merge(
197
- action_name.to_sym => { params: Array(params).map(&:to_sym) }
200
+ action_name.to_sym => { params: Array(params) }
198
201
  )
199
202
  end
200
203
 
@@ -213,13 +216,11 @@ module ReactiveComponent
213
216
  instance = allocate
214
217
  instance.instance_variable_set(:"@#{live_model_attr}", record)
215
218
 
216
- allowed = action_config[:params]
217
- if allowed.any?
218
- filtered = action_params.symbolize_keys.slice(*allowed)
219
- instance.send(action_name, **filtered)
220
- else
221
- instance.send(action_name)
222
- end
219
+ # `permit` (not `permit!` + slice): only declared keys, and only scalar
220
+ # values, so a nested hash or array never reaches the action method.
221
+ action_params = ActionController::Parameters.new(action_params) unless action_params.is_a?(ActionController::Parameters)
222
+ filtered = action_params.permit(*action_config[:params]).to_h.symbolize_keys
223
+ instance.send(action_name, **filtered)
223
224
  end
224
225
 
225
226
  def compiled_data
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Przemyslaw Lusar