lhs 16.1.0 → 16.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhs/concerns/proxy/accessors.rb +8 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/record/has_one_spec.rb +15 -6
- 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: 040a79027ac392157392edd52aa521fb295de1e5a7dc9e6450c08c55bb0998a2
|
4
|
+
data.tar.gz: 9689bd2cd92b51ce3c74072077a8219a8c844514c2efcda4d119f43f621b98fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a9e030f8741fe429bc56f43e48d9b694c1d7b7c3e296c7ec4b9d6cfdd3b123828dd115e9ac3371dc1ed0d01fc82cd029330422e8418d89053f9160c0fa8be4
|
7
|
+
data.tar.gz: 7503c74fe4756bb2086334253d06939f1ebc9a0b4cbfdadae460229c2ccc2243cba2acbf01c74593aaef0d81bcfc35937258ff360e05c9cf9262e9ba70861a03
|
@@ -77,7 +77,10 @@ class LHS::Proxy
|
|
77
77
|
data.errors = LHS::Problems::Nested::Errors.new(errors, name) if errors.any?
|
78
78
|
data.warnings = LHS::Problems::Nested::Warnings.new(warnings, name) if warnings.any?
|
79
79
|
return data.becomes(record) if record && !value.is_a?(LHS::Record)
|
80
|
-
|
80
|
+
if _record && _record._relations[name]
|
81
|
+
klass = _record._relations[name][:record_class_name].constantize
|
82
|
+
return cache.compute_if_absent(klass) { data.becomes(klass) }
|
83
|
+
end
|
81
84
|
data
|
82
85
|
end
|
83
86
|
|
@@ -104,5 +107,9 @@ class LHS::Proxy
|
|
104
107
|
def date_time_regex
|
105
108
|
/(?<date>\d{4}-\d{2}-\d{2})?(?<time>T\d{2}:\d{2}(:\d{2}(\.\d*.\d{2}:\d{2})*)?)?/
|
106
109
|
end
|
110
|
+
|
111
|
+
def cache
|
112
|
+
@cache ||= Concurrent::Map.new
|
113
|
+
end
|
107
114
|
end
|
108
115
|
end
|
data/lib/lhs/version.rb
CHANGED
data/spec/record/has_one_spec.rb
CHANGED
@@ -6,12 +6,14 @@ describe LHS::Record do
|
|
6
6
|
let(:user) { transaction.user }
|
7
7
|
|
8
8
|
before do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
[1, 2].each do |id|
|
10
|
+
stub_request(:get, "http://myservice/transactions/#{id}")
|
11
|
+
.to_return(body: {
|
12
|
+
user: {
|
13
|
+
email_address: 'steve@local.ch'
|
14
|
+
}
|
15
|
+
}.to_json)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'has_one' do
|
@@ -40,6 +42,13 @@ describe LHS::Record do
|
|
40
42
|
expect(user._root._raw).to eq transaction._raw
|
41
43
|
expect(user.parent._raw).to eq transaction._raw
|
42
44
|
end
|
45
|
+
|
46
|
+
it 'the relation is cached in memory' do
|
47
|
+
object_id = transaction.user.object_id
|
48
|
+
expect(transaction.user.object_id).to eql(object_id)
|
49
|
+
transaction2 = Transaction.find(2)
|
50
|
+
expect(transaction2.user.object_id).not_to eql(object_id)
|
51
|
+
end
|
43
52
|
end
|
44
53
|
|
45
54
|
context 'custom class_name' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 16.1.
|
4
|
+
version: 16.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|