remotable 0.6.4 → 0.7.0

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: 22d6df302d76f75f9abe3c32936decb50fde62e5c5daafadab330c06f4c1d4d8
4
- data.tar.gz: 78c86070eab49ff4a2f9165d25e2a7d7e029d32406efc5486e14734e67d2ef2b
3
+ metadata.gz: 322b872afa0abda8c2ce3ea8b971e22caf3ebb6df5899c4cd714ff0377277074
4
+ data.tar.gz: 7e2b9f0c28207accc89f1e61197d95f8812d64d52d05c2d5761b52add73f4334
5
5
  SHA512:
6
- metadata.gz: 15f59309c923c6ec21ec559852e65be75faeebd1c711eccffe09766451bb692e024b4eaa431614b27c9dc8f37c721213563951f2159030b7ce523865e26b5179
7
- data.tar.gz: 6baecf50d8df1c784b82352aed90ec4af6bfb83b0c81e004ccd5e2309d42a0c72f3f2067c17aaf34217fd848223fc0e74f26247de4a0fa97fd5056d8949a1f18
6
+ metadata.gz: 27cbf3c0b06b7aac4f44a193d2cff1cf7b304e4fb110fb033768c1722537bb37d423e10c8868dab64a70224ca8c73dd93ddf2f7e99385a89f628f451d0637bd6
7
+ data.tar.gz: e8906f1de4fe996a7a91964194b10bcc39cc05c0ee5aab632806d3f592c0f34057d6c1e8e66aacd9142b8cec159fba8ba1f373825a459792477fc9f86e35b673
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.7.0
4
+ * **Bugfix** Ensured ActiveRecord models were using Nosync's `ClassMethods` instead of the non-threadsafe `InstanceMethods`
5
+
3
6
  ### 0.6.4
4
7
  * **Feature** Added `Remotable.unsafe_nosync!` method to set `nosync` globally using a class variable. As the method name indicates, this is not threadsafe and should only be used for testing or other situations where thread safety is not an issue.
5
8
  * **Bugfix** Stopped deferring to `Thread.main` if `nosync` was unset on the current thread; while convenient for tests (see above), it ended up allowing requests to leak state if they were handled on the main thread.
@@ -17,6 +17,16 @@ module Remotable
17
17
 
18
18
 
19
19
  included do
20
+ extend Nosync
21
+
22
+ # Has to be re-defined _after_ Nosync is extended, which cannot
23
+ # be done as part of the ClassMethods module
24
+ def self.nosync?
25
+ return true if remote_model.nil?
26
+ return super if nosync_value?
27
+ Remotable.nosync?
28
+ end
29
+
20
30
  before_update :update_remote_resource, :unless => :nosync?
21
31
  before_create :create_remote_resource, :unless => :nosync?
22
32
  before_destroy :destroy_remote_resource, :unless => :nosync?
@@ -41,16 +51,10 @@ module Remotable
41
51
 
42
52
 
43
53
  module ClassMethods
44
- include Nosync
45
54
 
46
55
  attr_accessor :_remote_attribute_map, :_local_attribute_routes, :_expires_after,
47
56
  :_remote_timeout, :remotable_skip_validation_on_sync
48
57
 
49
- def nosync?
50
- return true if remote_model.nil?
51
- return super if nosync_value?
52
- Remotable.nosync?
53
- end
54
58
 
55
59
  # Sets the key with which a resource is identified remotely.
56
60
  # If no remote key is set, the remote key is assumed to be :id.
@@ -1,3 +1,3 @@
1
1
  module Remotable
2
- VERSION = "0.6.4"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -170,4 +170,17 @@ class RemotableTest < ActiveSupport::TestCase
170
170
  end
171
171
 
172
172
 
173
+
174
+ # ========================================================================= #
175
+ # ActiveRecordExtender #
176
+ # ========================================================================= #
177
+
178
+ test "should extend an ActiveRecord subclass with Nosync class methods" do
179
+ class Example5 < ActiveRecord::Base; self.table_name = "tenants"; end
180
+ Example5.remote_model BespokeModel.new
181
+ # Method is _only_ on the class version
182
+ assert Example5.respond_to?(:unsafe_nosync!)
183
+ end
184
+
185
+
173
186
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remotable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource