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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/ask/guests/active_record/session_store.rb +20 -4
- data/lib/ask/guests/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9acb2b6123b2a779e22b609c3c17152a49016caca90cdcea777cf0f96181abd8
|
|
4
|
+
data.tar.gz: b8f6033500564981252c7b587278a5c1a817ca72c0aadd82053e55ce2b86490e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
23
|
-
# documented on SessionBase
|
|
24
|
-
|
|
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 = {})
|
data/lib/ask/guests/version.rb
CHANGED