ask-guests 0.3.0 → 0.4.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: 8bec805817f573f8d9fcbc2b5e7bc7c0e6622aed391b4af6d61f02c3544f1c10
4
- data.tar.gz: 381594c955f847741546177fc5bb03ead0e71ed6baa62f5adc98277e736fa223
3
+ metadata.gz: 9acb2b6123b2a779e22b609c3c17152a49016caca90cdcea777cf0f96181abd8
4
+ data.tar.gz: b8f6033500564981252c7b587278a5c1a817ca72c0aadd82053e55ce2b86490e
5
5
  SHA512:
6
- metadata.gz: f97bf4428e04bfcb3fb018b76663b825ed46357419ec43ecd5bc2b3c5fe18463fcc8d9f42ecb6d26be59a43404f3d5fa04b1ee2c715983fa971b09c08318d1c5
7
- data.tar.gz: cdc1be08b4f0ef9c13e93625c16be13fb35198fbd0ed2b9d222fc76cde0989b1fc456804aee2bf8a5cc7016ad3cf4c5304e74833638ed9f898b5a54704aa9c6b
6
+ metadata.gz: 440b3ed03e52cd3f45fb4ed3728280c204ed208e92964169152e5b1f9430c5d5403fb3deaaa96b0c571d4dcd2bb2dc9bb45016af4825ec0a4f83a73b40d05085
7
+ data.tar.gz: 7d6fd7481e18503d2da74912b2de6c155084ec9007e9f81856430c2818d64b919f933f3b26c4e3f86be0364e291c1395ca8e6464c72e596de2fd106ab820239b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0] — 2026-09-21
4
+
5
+ ### Added
6
+
7
+ - **Lazy model resolution in `SessionStore`.** Pass `model_name: "GuestSession"`
8
+ instead of `model: GuestSession` and the constant is resolved at call time,
9
+ not at boot. A code reload that replaces the class never leaves the store
10
+ holding a stale object — so the host can configure the store once at boot
11
+ rather than re-applying it from a `to_prepare` hook. The constructor accepts
12
+ either keyword; passing neither raises `ArgumentError`.
13
+
3
14
  ## [0.3.0] — 2026-09-17
4
15
 
5
16
  ### Added
@@ -10,19 +10,35 @@ module Ask
10
10
  # has_many :work_requests, foreign_key: :guest_session_id, dependent: :destroy
11
11
  # end
12
12
  #
13
+ # Pass the class directly:
14
+ #
13
15
  # Ask::Guests.configure do |config|
14
16
  # config.store = Ask::Guests::ActiveRecord::SessionStore.new(model: GuestSession)
15
17
  # end
16
18
  #
19
+ # Or pass its name as a string — the constant is resolved at call time,
20
+ # not at boot, so a code reload that replaces the class never leaves the
21
+ # store holding a stale object:
22
+ #
23
+ # Ask::Guests.configure do |config|
24
+ # config.store = Ask::Guests::ActiveRecord::SessionStore.new(model_name: "GuestSession")
25
+ # end
26
+ #
17
27
  # Destroying a session destroys the record, so host associations
18
28
  # declared with +dependent: :destroy+ sweep owned records too.
19
29
  class SessionStore < Stores::Base
20
- attr_reader :model
30
+ # @return [Class] the model class. When created with +model_name+,
31
+ # resolved at call time so a reload replaces the class under the hood.
32
+ def model
33
+ @model || Object.const_get(@model_name)
34
+ end
21
35
 
22
- # @param model [Class] an ActiveRecord model class with the columns
23
- # documented on SessionBase
24
- def initialize(model:)
36
+ # @param model [Class, nil] an ActiveRecord model class with the
37
+ # columns documented on SessionBase
38
+ # @param model_name [String, nil] its name, resolved lazily at call time
39
+ def initialize(model: nil, model_name: nil)
25
40
  @model = model
41
+ @model_name = model_name
26
42
  end
27
43
 
28
44
  def create(attributes = {})
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Guests
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-guests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto