phlex-reactive 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25876f4b6f97e3cd517a4b5a575e3156ac7cadd4025e9f5cdf5f10b0bb001346
4
- data.tar.gz: f5ea2f6cee8e7b17f66725549e98f2bc9d1cc3c29cf90acfb2d1b88c1176e2ea
3
+ metadata.gz: 11c82575cc72017be4f81341c0c2f999d626fe88ed8b81a20cfde246a412fe12
4
+ data.tar.gz: '0996ececdc33cd2220a7a6517d49d1a59c5c583af891b937f1df32f433189a65'
5
5
  SHA512:
6
- metadata.gz: ec2bc617e5a888e268e6e746f85a225e92d88145114687be55b825c9659b2d9ef75b35d25d67d6dc950070acadf3f387b2d2608108f4b91d2a0dfcd8982495e1
7
- data.tar.gz: c2249b5dd3783ec5f9d4881290e15030ca4de9e6e4e1af238f239feb55c63df76a5c5f4d1098e9bb1022547766752a03825b63d7dac60830dcc6cd5526d929ca
6
+ metadata.gz: 24b3704443cd08380e30bb2bd4340d266a75a39beb80247a4ba26327a4c6f6429b0017fc94618b4063dc4f00a7a86f49ab88074c008d9be1c2ead0b266b5c8cd
7
+ data.tar.gz: 4f858ded4f109ce0350603140572b4d9c694acd981785ac1913c0cf4c48630e6927d223073cd89fbb1f6a72e16bf7cea0603079661fff7b80740a4389ccbe732
data/CHANGELOG.md CHANGED
@@ -6,6 +6,37 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Fixed
10
+
11
+ - **Record-backed component built with a different init keyword by the action
12
+ endpoint vs the broadcast path.** The click path (`Component.from_identity`)
13
+ builds with `reactive_record_key` (the `reactive_record :name`), but the
14
+ broadcast path (`Streamable.build` → `model_param_name`) built with the
15
+ demodulized, underscored class name. They only agreed when the class name
16
+ happened to equal the record name — otherwise one path worked and the other
17
+ raised `ArgumentError: missing keyword`. The README's own `Todos::Item`
18
+ (`reactive_record :todo`, `Item` ≠ `todo`) hit this on broadcast.
19
+ `model_param_name` now prefers `reactive_record_key` when set, so a single
20
+ `initialize(<record>:)` satisfies both clicks and broadcasts. `Streamable`-only
21
+ components (no `reactive_record`) keep the demodulized-class-name default, and
22
+ an explicit `def self.model_param_name` override still wins. No API changes.
23
+ Closes #4.
24
+
25
+ ## [0.2.1]
26
+
27
+ ### Fixed
28
+
29
+ - **Zeitwerk eager-load crash in host apps.** A host app with
30
+ `config.eager_load = true` (the production default) runs
31
+ `Zeitwerk::Loader.eager_load_all`, which walked this gem's loader and raised
32
+ `Zeitwerk::NameError` on two files that don't follow Zeitwerk's
33
+ file→constant rule: `version.rb` (defines `VERSION`, not `Version`) and the
34
+ Rails generators under `lib/generators` (whose path/constant scheme is
35
+ intentionally non-Zeitwerk). The loader now requires `version.rb` up front and
36
+ ignores it, and ignores `lib/generators` (Rails loads generators itself), so
37
+ the gem eager-loads cleanly. Added a regression spec that calls
38
+ `eager_load_all`. No API changes.
39
+
9
40
  ## [0.2.0]
10
41
 
11
42
  ### Added
@@ -49,6 +80,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
49
80
  scaffolds a reactive component (and an RSpec spec when the app uses RSpec),
50
81
  state-backed by default or record-backed with `--record`.
51
82
 
52
- [Unreleased]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.0...HEAD
83
+ [Unreleased]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.1...HEAD
84
+ [0.2.1]: https://github.com/mhenrixon/phlex-reactive/compare/v0.2.0...v0.2.1
53
85
  [0.2.0]: https://github.com/mhenrixon/phlex-reactive/compare/v0.1.0...v0.2.0
54
86
  [0.1.0]: https://github.com/mhenrixon/phlex-reactive/releases/tag/v0.1.0
@@ -27,11 +27,19 @@ module Phlex
27
27
  extend ActiveSupport::Concern
28
28
 
29
29
  class_methods do
30
- # The keyword the positional model maps to in `initialize`. Convention:
31
- # demodulized, underscored class name (Invoice -> :invoice,
32
- # InvoiceItem -> :invoice_item). Override when it differs.
30
+ # The keyword the positional model maps to in `initialize`. For a
31
+ # record-backed component (Component#reactive_record), this is the SAME
32
+ # keyword the action endpoint uses in `from_identity` — so one
33
+ # `initialize(<record>:)` satisfies BOTH the click path and the
34
+ # broadcast path. Otherwise it falls back to the demodulized, underscored
35
+ # class name (Invoice -> :invoice, InvoiceItem -> :invoice_item).
36
+ # Override when it differs.
33
37
  def model_param_name
34
- name.demodulize.underscore.to_sym
38
+ if respond_to?(:reactive_record_key) && reactive_record_key
39
+ reactive_record_key
40
+ else
41
+ name.demodulize.underscore.to_sym
42
+ end
35
43
  end
36
44
 
37
45
  def component_args(model, options)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlex
4
4
  module Reactive
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
@@ -3,6 +3,12 @@
3
3
  require "zeitwerk"
4
4
  require "globalid"
5
5
 
6
+ # VERSION is a plain constant, not a Zeitwerk-managed file (it defines VERSION,
7
+ # not Version). Require it up front and ignore the file below so the loader
8
+ # never tries to load it — otherwise eager_load_all (host app with
9
+ # config.eager_load = true) raises Zeitwerk::NameError.
10
+ require_relative "reactive/version"
11
+
6
12
  module Phlex
7
13
  # phlex-reactive: reactive Phlex components for Rails.
8
14
  #
@@ -125,8 +131,23 @@ end
125
131
 
126
132
  loader = Zeitwerk::Loader.new
127
133
  loader.tag = "phlex-reactive"
128
- loader.push_dir(File.expand_path("..", __dir__))
129
- loader.ignore("#{__dir__}/../phlex-reactive.rb")
134
+ # Root is lib/ so files map to the Phlex::Reactive namespace
135
+ # (lib/phlex/reactive/foo.rb -> Phlex::Reactive::Foo).
136
+ lib = File.expand_path("..", __dir__)
137
+ loader.push_dir(lib)
138
+ # The gem-name shim (`require "phlex-reactive"`) is a plain require, not a
139
+ # managed file.
140
+ loader.ignore("#{lib}/phlex-reactive.rb")
141
+ # version.rb defines VERSION (a constant, not a `Version` class) and is required
142
+ # above — Zeitwerk must not try to load it.
143
+ loader.ignore("#{lib}/phlex/reactive/version.rb")
144
+ # Rails generators are discovered and loaded by Rails' own generator system,
145
+ # not the app autoloader. Their path/constant scheme
146
+ # (generators/phlex/reactive/... defining Phlex::Reactive::Generators::...)
147
+ # deliberately doesn't follow Zeitwerk's rules, so the loader must ignore them.
148
+ loader.ignore("#{lib}/generators")
149
+ # The engine is required explicitly below (only when Rails is present) and must
150
+ # not be eager-loaded before that.
130
151
  loader.do_not_eager_load("#{__dir__}/reactive/engine.rb")
131
152
  loader.setup
132
153
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex-reactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson