jetstream_bridge 1.13.0 → 1.14.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/Gemfile.lock +1 -1
- data/lib/jetstream_bridge/inbox_event.rb +21 -10
- data/lib/jetstream_bridge/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: 649a6258b0dce4c43433916df6bb2f9c5d41ba233f05ce66b935853b16637b64
|
4
|
+
data.tar.gz: 942589e88710ac2da1651baa5cee79dbd2304db0fa15a12a8c9d911c8d05ef44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10540646b48b7d605f5f92915d4d8be5aed2f72578a151c3f2e4bc500a2908df4c216f1baa0dc128fddd502ca4f88ef73e6c27bb56ab9174573619a298893d4e
|
7
|
+
data.tar.gz: 0debe41380866ee0253570f87b7a3f13dbdbdd3456cbc655815da586612d36155df1f169ba5f321f037b0031f50552f6e8d5e82b04f52f49b41f4e05eb1c1a40
|
data/Gemfile.lock
CHANGED
@@ -15,6 +15,7 @@ module JetstreamBridge
|
|
15
15
|
# Safe column presence check that never boots a connection during class load.
|
16
16
|
def has_column?(name)
|
17
17
|
return false unless ar_connected?
|
18
|
+
|
18
19
|
connection.schema_cache.columns_hash(table_name).key?(name.to_s)
|
19
20
|
rescue ActiveRecord::ConnectionNotEstablished, ActiveRecord::NoDatabaseError
|
20
21
|
false
|
@@ -22,7 +23,7 @@ module JetstreamBridge
|
|
22
23
|
|
23
24
|
def ar_connected?
|
24
25
|
ActiveRecord::Base.connected? && connection_pool.active_connection?
|
25
|
-
rescue
|
26
|
+
rescue StandardError
|
26
27
|
false
|
27
28
|
end
|
28
29
|
end
|
@@ -42,7 +43,7 @@ module JetstreamBridge
|
|
42
43
|
|
43
44
|
validates :stream_seq,
|
44
45
|
uniqueness: { scope: :stream },
|
45
|
-
if:
|
46
|
+
if: lambda {
|
46
47
|
!self.class.has_column?(:event_id) &&
|
47
48
|
self.class.has_column?(:stream_seq) &&
|
48
49
|
self.class.has_column?(:stream)
|
@@ -50,7 +51,7 @@ module JetstreamBridge
|
|
50
51
|
|
51
52
|
validates :stream_seq,
|
52
53
|
uniqueness: true,
|
53
|
-
if:
|
54
|
+
if: lambda {
|
54
55
|
!self.class.has_column?(:event_id) &&
|
55
56
|
self.class.has_column?(:stream_seq) &&
|
56
57
|
!self.class.has_column?(:stream)
|
@@ -62,8 +63,10 @@ module JetstreamBridge
|
|
62
63
|
|
63
64
|
# ---- Defaults that do not require schema at load time ----
|
64
65
|
before_validation do
|
65
|
-
self.status
|
66
|
-
|
66
|
+
self.status ||= 'received' if self.class.has_column?(:status) && status.blank?
|
67
|
+
if self.class.has_column?(:received_at) && received_at.blank?
|
68
|
+
self.received_at ||= Time.now.utc
|
69
|
+
end
|
67
70
|
end
|
68
71
|
|
69
72
|
# ---- Helpers ----
|
@@ -80,8 +83,12 @@ module JetstreamBridge
|
|
80
83
|
def payload_hash
|
81
84
|
v = self[:payload]
|
82
85
|
case v
|
83
|
-
when String then
|
84
|
-
|
86
|
+
when String then begin
|
87
|
+
JSON.parse(v)
|
88
|
+
rescue StandardError
|
89
|
+
{}
|
90
|
+
end
|
91
|
+
when Hash then v
|
85
92
|
else v.respond_to?(:as_json) ? v.as_json : {}
|
86
93
|
end
|
87
94
|
end
|
@@ -93,14 +100,18 @@ module JetstreamBridge
|
|
93
100
|
def method_missing(method_name, *_args, &_block)
|
94
101
|
raise_missing_ar!('Inbox', method_name)
|
95
102
|
end
|
96
|
-
|
103
|
+
|
104
|
+
def respond_to_missing?(_m, _p = false)
|
105
|
+
false
|
106
|
+
end
|
97
107
|
|
98
108
|
private
|
109
|
+
|
99
110
|
def raise_missing_ar!(which, method_name)
|
100
111
|
raise(
|
101
112
|
"#{which} requires ActiveRecord (tried to call ##{method_name}). " \
|
102
|
-
|
103
|
-
|
113
|
+
'Enable `use_inbox` only in apps with ActiveRecord, or add ' \
|
114
|
+
'`gem \"activerecord\"` to your Gemfile.'
|
104
115
|
)
|
105
116
|
end
|
106
117
|
end
|