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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6196adf923e1dff8c5d62c9e2e617234b701de9337e915bb09496d4ad625e9ff
4
- data.tar.gz: e7f0ee0c49ae92a0304ad0e1e3e221c37c124420c30653cbcbed6e67d24e77c1
3
+ metadata.gz: 649a6258b0dce4c43433916df6bb2f9c5d41ba233f05ce66b935853b16637b64
4
+ data.tar.gz: 942589e88710ac2da1651baa5cee79dbd2304db0fa15a12a8c9d911c8d05ef44
5
5
  SHA512:
6
- metadata.gz: 535122ca803451429cbd3ee1e5d56b6f6f45e7412a1bdbd0bfb210970641a3d3ada9d8f1f0737751cc0f330494b43a0912f52b596974dc271ab1bd8e33c77a70
7
- data.tar.gz: 599b1ddc980439dc84d032fc3c855ac059f66c55fe8f6e55e27bc55e5f93f0555c6c41a74c64e250996f642cb4a738af66cd841283c1b496a5487ce0a0c96a52
6
+ metadata.gz: 10540646b48b7d605f5f92915d4d8be5aed2f72578a151c3f2e4bc500a2908df4c216f1baa0dc128fddd502ca4f88ef73e6c27bb56ab9174573619a298893d4e
7
+ data.tar.gz: 0debe41380866ee0253570f87b7a3f13dbdbdd3456cbc655815da586612d36155df1f169ba5f321f037b0031f50552f6e8d5e82b04f52f49b41f4e05eb1c1a40
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jetstream_bridge (1.13.0)
4
+ jetstream_bridge (1.14.0)
5
5
  activerecord (>= 6.0)
6
6
  activesupport (>= 6.0)
7
7
  nats-pure (~> 2.4)
@@ -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 ||= 'received' if self.class.has_column?(:status) && status.blank?
66
- self.received_at ||= Time.now.utc if self.class.has_column?(:received_at) && received_at.blank?
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 JSON.parse(v) rescue {}
84
- when Hash then v
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
- def respond_to_missing?(_m, _p = false) = false
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
- 'Enable `use_inbox` only in apps with ActiveRecord, or add ' \
103
- '`gem \"activerecord\"` to your Gemfile.'
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
@@ -4,5 +4,5 @@
4
4
  #
5
5
  # Version constant for the gem.
6
6
  module JetstreamBridge
7
- VERSION = '1.13.0'
7
+ VERSION = '1.14.0'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jetstream_bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Attara