deimos-ruby 1.8.1.pre.beta4 → 1.8.1.pre.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb7b72866d42e8a74dfe9e441b5e1436c81cb16684d2985840980c010416e8af
4
- data.tar.gz: 97b806b1b52807ea487a0da20099450d005bf71ac4cd88fbc5eb50aae66726bb
3
+ metadata.gz: 516d09f0dc29c3388d1885c67d7faf3c2f240eede7278ad1ac76dfa46727e4e7
4
+ data.tar.gz: c9fcf141d5dfca3de041d82079f773c53b6a2f663fe7a8b3aa5fbee28964fb19
5
5
  SHA512:
6
- metadata.gz: 0d98923fd57076e391a9e8e1c2a6afb83fbde7769d646fc88d599921d9b0d55a6b1c7bd0df7f3344c71c66915766484bd0c9c19cfa72fef7f9299ab41cf66232
7
- data.tar.gz: c537564c70e3d297ca76000cd683f6c0891c18dc3b54d95b9aa6f3ea4b390a59fd2992d070112afc1e562c0bc59e0a4b523cb7bd4d71efafe2b03083df5273a6
6
+ metadata.gz: f4b5feee05510a8e6c9d85c9af85aff48f01c43419b5e5600a853d60a62d4b06f8430bb91b11047f6fd2579f23a89e8b9cbafe41a40ed84f7448a54b47115587
7
+ data.tar.gz: e4c1a0b181f4e5289f995056338b78cab4a8da3cb50863e70ba9f78e8526e470a52a035eaa3a34a0261b1ad14dbff41d2e25a3ffff5e75218408e31aa94a9ed0
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ ## 1.8.1-beta5 - 2020-08-13
11
+
12
+ ### Fixes :wrench:
13
+ - Fix regression bug which introduces backwards incompatibility
14
+ with ActiveRecordProducer's `record_attributes` method.
15
+
10
16
  ## 1.8.1-beta4 - 2020-08-12
11
17
 
12
18
  ### Fixes :wrench:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.8.1.pre.beta3)
4
+ deimos-ruby (1.8.1.pre.beta4)
5
5
  avro_turf (~> 0.11)
6
6
  phobos (~> 1.9)
7
7
  ruby-kafka (~> 0.7)
data/README.md CHANGED
@@ -599,7 +599,7 @@ class MyConsumer < Deimos::ActiveRecordConsumer
599
599
 
600
600
  # Optional override to change the attributes of the record before they
601
601
  # are saved.
602
- def record_attributes(payload)
602
+ def record_attributes(payload, key)
603
603
  super.merge(:some_field => 'some_value')
604
604
  end
605
605
 
@@ -680,7 +680,7 @@ class MyConsumer < Deimos::ActiveRecordConsumer
680
680
 
681
681
  # Optional override to change the attributes of the record before they
682
682
  # are saved.
683
- def record_attributes(payload)
683
+ def record_attributes(payload, key)
684
684
  super.merge(:some_field => 'some_value')
685
685
  end
686
686
  end
@@ -88,8 +88,13 @@ module Deimos
88
88
 
89
89
  # Create payloads with payload + key attributes
90
90
  upserts = messages.map do |m|
91
- record_attributes(m.payload, m.key)&.
92
- merge(record_key(m.key))
91
+ attrs = if self.method(:record_attributes).parameters.size == 2
92
+ record_attributes(m.payload, m.key)
93
+ else
94
+ record_attributes(m.payload)
95
+ end
96
+
97
+ attrs&.merge(record_key(m.key))
93
98
  end
94
99
 
95
100
  # If overridden record_attributes indicated no record, skip
@@ -37,7 +37,14 @@ module Deimos
37
37
  record = klass.new
38
38
  assign_key(record, payload, key)
39
39
  end
40
- attrs = record_attributes(payload.with_indifferent_access, key)
40
+
41
+ # for backwards compatibility
42
+ # TODO next major release we should deprecate this
43
+ attrs = if self.method(:record_attributes).parameters.size == 2
44
+ record_attributes(payload.with_indifferent_access, key)
45
+ else
46
+ record_attributes(payload.with_indifferent_access)
47
+ end
41
48
  # don't use attributes= - bypass Rails < 5 attr_protected
42
49
  attrs.each do |k, v|
43
50
  record.send("#{k}=", v)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.8.1-beta4'
4
+ VERSION = '1.8.1-beta5'
5
5
  end
@@ -30,6 +30,7 @@ describe Deimos::KafkaListener do
30
30
  end
31
31
 
32
32
  it 'should listen to publishing errors and republish as Deimos events' do
33
+ allow(Deimos::Producer).to receive(:descendants).and_return([MyProducer])
33
34
  Deimos.subscribe('produce_error') do |event|
34
35
  expect(event.payload).to include(
35
36
  producer: MyProducer,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1.pre.beta4
4
+ version: 1.8.1.pre.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-12 00:00:00.000000000 Z
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf