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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/remotable/active_record_extender.rb +10 -6
- data/lib/remotable/version.rb +1 -1
- data/test/remotable_test.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322b872afa0abda8c2ce3ea8b971e22caf3ebb6df5899c4cd714ff0377277074
|
4
|
+
data.tar.gz: 7e2b9f0c28207accc89f1e61197d95f8812d64d52d05c2d5761b52add73f4334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27cbf3c0b06b7aac4f44a193d2cff1cf7b304e4fb110fb033768c1722537bb37d423e10c8868dab64a70224ca8c73dd93ddf2f7e99385a89f628f451d0637bd6
|
7
|
+
data.tar.gz: e8906f1de4fe996a7a91964194b10bcc39cc05c0ee5aab632806d3f592c0f34057d6c1e8e66aacd9142b8cec159fba8ba1f373825a459792477fc9f86e35b673
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
data/lib/remotable/version.rb
CHANGED
data/test/remotable_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|