smart_properties 1.16.0 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_properties/property_collection.rb +5 -4
- data/lib/smart_properties/version.rb +1 -1
- data/spec/inheritance_spec.rb +53 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d970dbdc63b4c78e01ec7f569bd00d9c37a61c672f97d084a5a01b205c80159
|
4
|
+
data.tar.gz: 0db3dca56f41fafc8c96cef4c2ebd54068ce505101a3f949549724522b88bf3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 186ffbca4f484bd2dcf39fef28bf49523323d195c515567266dfe1c1166b513a426b8da3548a350025d11ca4188984ad312302198ec8d365de00d120b93921a5
|
7
|
+
data.tar.gz: dffb5d926bc985cf751d654782d152acb38ef1a9b1febd9ccec9bb2589fb61e55b6f471d83d82f106d2f504b1276c2f00166ff18b2f3ea48fc550687d60cf5de
|
@@ -11,9 +11,10 @@ module SmartProperties
|
|
11
11
|
ancestor != SmartProperties
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
collection = new
|
15
|
+
|
16
|
+
parents.reverse.each do |parent|
|
17
|
+
parent.properties.register(collection)
|
17
18
|
end
|
18
19
|
|
19
20
|
collection
|
@@ -75,7 +76,7 @@ module SmartProperties
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def refresh(parent_collection)
|
78
|
-
@collection_with_parent_collection
|
79
|
+
@collection_with_parent_collection.merge!(parent_collection)
|
79
80
|
notify_children
|
80
81
|
nil
|
81
82
|
end
|
data/spec/inheritance_spec.rb
CHANGED
@@ -226,33 +226,67 @@ RSpec.describe SmartProperties, 'intheritance' do
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
-
|
230
|
-
m
|
231
|
-
|
232
|
-
|
229
|
+
context "through modules" do
|
230
|
+
let(:m) do
|
231
|
+
m = Module.new do
|
232
|
+
include SmartProperties
|
233
|
+
property :m, default: 1
|
234
|
+
end
|
233
235
|
end
|
234
236
|
|
235
|
-
n
|
236
|
-
|
237
|
-
|
237
|
+
let(:n) do
|
238
|
+
n = Module.new do
|
239
|
+
include SmartProperties
|
240
|
+
property :n, default: 2
|
241
|
+
end
|
238
242
|
end
|
239
243
|
|
240
|
-
|
244
|
+
it "is supported" do
|
245
|
+
n = self.n
|
246
|
+
m = self.m
|
247
|
+
o = Module.new {}
|
241
248
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
249
|
+
klass = Class.new do
|
250
|
+
include m
|
251
|
+
include o
|
252
|
+
include n
|
253
|
+
end
|
254
|
+
|
255
|
+
n.module_eval do
|
256
|
+
property :p, default: 3
|
257
|
+
end
|
258
|
+
|
259
|
+
instance = klass.new
|
260
|
+
|
261
|
+
expect(instance.m).to eq(1)
|
262
|
+
expect(instance.n).to eq(2)
|
263
|
+
expect(instance.p).to eq(3)
|
247
264
|
|
248
|
-
|
249
|
-
property :p, default: 3
|
265
|
+
expect { klass.new(m: 4, n: 5, p: 6) }.to_not raise_error
|
250
266
|
end
|
251
267
|
|
252
|
-
|
268
|
+
it "yields properly ordered properties – child properties have higher precedence than parent properties" do
|
269
|
+
n = self.n
|
270
|
+
m = self.m
|
253
271
|
|
254
|
-
|
255
|
-
|
256
|
-
|
272
|
+
parent = Class.new do
|
273
|
+
include m
|
274
|
+
include n
|
275
|
+
end
|
276
|
+
expect(parent.new.m).to eq(1)
|
277
|
+
|
278
|
+
child = Class.new(parent) do
|
279
|
+
property :m, default: 0
|
280
|
+
end
|
281
|
+
expect(child.new.m).to eq(0)
|
282
|
+
|
283
|
+
grandchild = Class.new(child)
|
284
|
+
expect(grandchild.new.m).to eq(0)
|
285
|
+
|
286
|
+
grandgrandchild = Class.new(grandchild) do
|
287
|
+
property :m, default: 1000
|
288
|
+
end
|
289
|
+
expect(grandgrandchild.new.m).to eq(1000)
|
290
|
+
end
|
257
291
|
end
|
258
292
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_properties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Tennhard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.2.
|
116
|
+
rubygems_version: 3.2.20
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: SmartProperties – Ruby accessors on steroids
|