switchman 3.5.0 → 3.5.1

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: 1f6f878b1a2a9ba1dc0c75ce4fcd5d299178ea7940a048190bd4b181ae306339
4
- data.tar.gz: 19b31ce1e456fbecf2a9ba9b15644bc6073cd521b6a604da81a0c5f8977f579a
3
+ metadata.gz: f381ad09908e23b0560c685c530f7ffae1a0adcbbaf6640b5ae4f267dd9323f3
4
+ data.tar.gz: 1ca68afa9a03005c7c5966f8bc8a6be06f552c086ca469fe4b9eab1a54e819ae
5
5
  SHA512:
6
- metadata.gz: bad542adf6c09d1e1e50ef3054a8ca8d106bd3eedb7cb9dbbe544e44dd88c7f19226e7dd0d805ad5a5685009be7b9c9fe20623182c8c624c88724d00d7bc5656
7
- data.tar.gz: 43b76369798a3683f838e392466cec0628d0c4a309354db7ccadcafca604f6eeffdcc460e036ca8d0f105c7abed2987baa23d51b830e628951c057adb554f305
6
+ metadata.gz: 3340807bd81183c24527ba2739732e6ac5aa413d1184c22d4b1ad2d3cc0674b5222d1cf5ddb7abad158108a35e6c226bf9c7614f55fc890debbee0f20147ef98
7
+ data.tar.gz: e67e961f5f4085ed7d0b00c272d8f8c911d14b284415e8bab2f528c25177db8504c8c7e8ceafa5e4ac5389e0f3f548f8d069838e21c6f8099864a91d5655d5a9
@@ -5,10 +5,12 @@ module Switchman
5
5
  module Persistence
6
6
  # touch reads the id attribute directly, so it's not relative to the current shard
7
7
  def touch(*, **)
8
+ writable_shadow_record_warning
8
9
  shard.activate(self.class.connection_class_for_self) { super }
9
10
  end
10
11
 
11
12
  def update_columns(*)
13
+ writable_shadow_record_warning
12
14
  shard.activate(self.class.connection_class_for_self) { super }
13
15
  end
14
16
 
@@ -17,6 +19,16 @@ module Switchman
17
19
  db.unguard { super }
18
20
  end
19
21
 
22
+ def destroy
23
+ writable_shadow_record_warning
24
+ super
25
+ end
26
+
27
+ def create_or_update(**, &block)
28
+ writable_shadow_record_warning
29
+ super
30
+ end
31
+
20
32
  def reload(*)
21
33
  res = super
22
34
  # When a shadow record is reloaded the real record is returned. So
@@ -24,6 +36,12 @@ module Switchman
24
36
  @loaded_from_shard = @shard
25
37
  res
26
38
  end
39
+
40
+ def writable_shadow_record_warning
41
+ return unless shadow_record? && Switchman.config[:writable_shadow_records]
42
+
43
+ Switchman::Deprecation.warn("writing to shadow records is not supported")
44
+ end
27
45
  end
28
46
  end
29
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "3.5.0"
4
+ VERSION = "3.5.1"
5
5
  end
data/lib/switchman.rb CHANGED
@@ -18,6 +18,8 @@ loader.inflector = SwitchmanInflector.new(__FILE__)
18
18
  loader.setup
19
19
 
20
20
  module Switchman
21
+ Deprecation = ::ActiveSupport::Deprecation.new("4.0", "Switchman")
22
+
21
23
  def self.config
22
24
  # TODO: load from yaml
23
25
  @config ||= {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-05-02 00:00:00.000000000 Z
13
+ date: 2023-05-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord