table_sync 6.4.0 → 6.4.1

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: e58ec3bb926b9efd5452696c0b3c2a006559cb30ee21cd48b66c0883e1cdaffd
4
- data.tar.gz: d120b0e941915d3b53a91c79d9a0d5d33b46cb01b1a2b9747470c15228bdbf8f
3
+ metadata.gz: '04790df8ae9da785364a1ba3d01c7e167183a3c1334257e245eb74fc2894efc4'
4
+ data.tar.gz: e3fc4d152b0734bf90fc6ec2138aaf155a68563c225b1e00e6167f8595a0f1a5
5
5
  SHA512:
6
- metadata.gz: bb0aa2b6c60faee79bd1d16cab3d16fc8e741077209abc54b7bbd7da32e075c990cb7e074a2d8ff149b502ea6900e148794f730d48fa4d646fc877c235d872d6
7
- data.tar.gz: 6c416eb72fbcf7bb5fcfe758d6ec7408fd89d0353fb9be72f7181e41bc287e6bd86e4e06a50b6fee78c69b558c3e11d1a590c451438d43bb2444079fe5c39e61
6
+ metadata.gz: 0e0559fa23809ca3196ee800c95a29c99f10cd1a96db6a7839e807a4caa3862feb41213c52349cc818a22e5e6e6d926d74d129e7a31bfba7080d5c339dea5789
7
+ data.tar.gz: a3b259534e55aa2191f90df43257de259f8e31b9187763b9952d09fb3d2fb4cc81b178d6bf3fd6769089cc7adc361420183878b22cc2e95ff2732c6b33598ae9
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [6.4.1] - 2023-08-15
5
+ ### Added
6
+ - Required fields validation for the Raw and Batch publishers.
7
+
8
+ ## [6.4.0] - 2023-08-15
9
+ ### Changed
10
+ - Fix sort in receiving (#79).
11
+
4
12
  ## [6.3.0] - 2023-07-24
5
13
  ### Changed
6
14
  - Send all original attributes for `delete` events instead of just PK.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- table_sync (6.4.0)
4
+ table_sync (6.4.1)
5
5
  memery
6
6
  rabbit_messaging (~> 0.13)
7
7
  rails
@@ -2,6 +2,7 @@
2
2
 
3
3
  class TableSync::Publishing::Batch
4
4
  include Tainbox
5
+ include TableSync::Utils::RequiredValidator
5
6
 
6
7
  attribute :object_class
7
8
  attribute :original_attributes
@@ -11,6 +12,8 @@ class TableSync::Publishing::Batch
11
12
 
12
13
  attribute :event, default: :update
13
14
 
15
+ require_attributes :object_class, :original_attributes
16
+
14
17
  def publish_later
15
18
  job.perform_later(job_attributes)
16
19
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  class TableSync::Publishing::Raw
4
4
  include Tainbox
5
+ include TableSync::Utils::RequiredValidator
5
6
 
6
7
  attribute :model_name
7
8
  attribute :table_name
@@ -13,6 +14,8 @@ class TableSync::Publishing::Raw
13
14
 
14
15
  attribute :event, default: :update
15
16
 
17
+ require_attributes :model_name, :original_attributes
18
+
16
19
  def publish_now
17
20
  message.publish
18
21
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TableSync::Utils::RequiredValidator
4
+ module PrependedInitialization
5
+ def initialize(*)
6
+ super
7
+
8
+ not_filled_attrs = calculate_not_filled_attributes
9
+ if not_filled_attrs.present?
10
+ raise(
11
+ ArgumentError,
12
+ "Some of required attributes is not provided: #{not_filled_attrs.inspect}",
13
+ )
14
+ end
15
+ end
16
+ end
17
+
18
+ module ClassMethods
19
+ def require_attributes(*attributes)
20
+ _required_attributes.push(*attributes)
21
+ end
22
+
23
+ def _required_attributes
24
+ @_required_attributes ||= []
25
+ end
26
+ end
27
+
28
+ module InstanceMethods
29
+ private
30
+
31
+ def calculate_not_filled_attributes
32
+ attributes
33
+ .select { |key, value| key.in?(self.class._required_attributes) && value.blank? }
34
+ .keys
35
+ end
36
+ end
37
+
38
+ def self.included(klass)
39
+ klass.prepend(PrependedInitialization)
40
+ klass.extend(ClassMethods)
41
+ klass.include(InstanceMethods)
42
+ end
43
+ end
@@ -5,5 +5,6 @@ module TableSync
5
5
  require_relative "utils/proc_array"
6
6
  require_relative "utils/proc_keywords_resolver"
7
7
  require_relative "utils/interface_checker"
8
+ require_relative "utils/required_validator"
8
9
  end
9
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TableSync
4
- VERSION = "6.4.0"
4
+ VERSION = "6.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0
4
+ version: 6.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Umbrellio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-15 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -127,6 +127,7 @@ files:
127
127
  - lib/table_sync/utils/interface_checker.rb
128
128
  - lib/table_sync/utils/proc_array.rb
129
129
  - lib/table_sync/utils/proc_keywords_resolver.rb
130
+ - lib/table_sync/utils/required_validator.rb
130
131
  - lib/table_sync/version.rb
131
132
  - log/.keep
132
133
  - table_sync.gemspec