smart_properties 1.16.0 → 1.16.2

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: 76b840210991bfec855a2e1159426635bc29e3994269bf305b5f0a8fe40fb0cf
4
- data.tar.gz: f10d37b213920338b36b8a2da7bbecc1e8e0caf1d6eecf66084b6cbb4914a95e
3
+ metadata.gz: 3d970dbdc63b4c78e01ec7f569bd00d9c37a61c672f97d084a5a01b205c80159
4
+ data.tar.gz: 0db3dca56f41fafc8c96cef4c2ebd54068ce505101a3f949549724522b88bf3f
5
5
  SHA512:
6
- metadata.gz: 30f8ed85cd3db3e2c17ddc30b63f85cba5541d26d8c8747a92529320531c11a58ae20435f08175061faedc7edf8f3bad2899ff32f2aa36465d4de2a78c8ca75e
7
- data.tar.gz: fb602a52c408989d44c9ef0dd232f5891c6bc96f64444d077d498bb06ed1f63dfa671712abfe9ab0680214fb442ee4b029b6e0e518df01a35860e5fc6c072151
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
- parents.reduce(collection = new) do |previous, current|
15
- current.properties.register(previous)
16
- current.properties
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 = parent_collection.merge(collection)
79
+ @collection_with_parent_collection.merge!(parent_collection)
79
80
  notify_children
80
81
  nil
81
82
  end
@@ -1,3 +1,3 @@
1
1
  module SmartProperties
2
- VERSION = "1.16.0"
2
+ VERSION = "1.16.2"
3
3
  end
@@ -226,33 +226,67 @@ RSpec.describe SmartProperties, 'intheritance' do
226
226
  end
227
227
  end
228
228
 
229
- it "supports multiple inheritance through modules" do
230
- m = Module.new do
231
- include SmartProperties
232
- property :m, default: 1
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 = Module.new do
236
- include SmartProperties
237
- property :n, default: 2
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
- o = Module.new {}
244
+ it "is supported" do
245
+ n = self.n
246
+ m = self.m
247
+ o = Module.new {}
241
248
 
242
- klass = Class.new do
243
- include m
244
- include o
245
- include n
246
- end
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
- n.module_eval do
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
- instance = klass.new
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
- expect(instance.m).to eq(1)
255
- expect(instance.n).to eq(2)
256
- expect(instance.p).to eq(3)
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.0
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-08-18 00:00:00.000000000 Z
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.3
116
+ rubygems_version: 3.2.20
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: SmartProperties – Ruby accessors on steroids