praxis-mapper 4.1 → 4.1.1

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
  SHA1:
3
- metadata.gz: 534dfb921f690285f07345acfe42725bdc8cef94
4
- data.tar.gz: 603a6f23b61c9734595fc2358bc01f2d08de439f
3
+ metadata.gz: 0d6680ca8a7a141d49b78517c33a45305cba5ac1
4
+ data.tar.gz: c9fe79656d4ae8d65b00d91a8aa1f31f8c43c264
5
5
  SHA512:
6
- metadata.gz: 09b91f6256a04bc776a3aabc82e1b070182c2a03ecdfd9d86edb5abcee01f06529d99f0bb5667a2fc202d5089370799f19f226f5e869ae676339802b385f1f88
7
- data.tar.gz: 88dec0ce7600e96e87bc08963f8228c18e0b963ebbaa2da448a550e5287bc6331c330559d75d574b681052f5de4d67a5cb64f614b5067bb2e4b743e09f3d9357
6
+ metadata.gz: b194a3a75bc1a36cb1d62b977ba63fef76c968c1c2927b6c2e2404925a89a82a49defd02d355b8e0578fc5f6126d3602cb9339d840d69ad3e31e19831f1e1031
7
+ data.tar.gz: 0c7f61c1b671de5ed918c3e2591b2dbdd1bfd6867353a88fc66784e4e347d9b3fc94b3698b5f3a46a003f00c8e64283429a4bc3be9025ba0732c7ee79353319c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## next
4
4
 
5
+ ## 4.1.1
6
+
7
+ * Fixed critical bug in `IdentityMap#finalize!`=
8
+
9
+
5
10
  ## 4.1
6
11
 
7
12
  * Added instrumentation through `ActiveSupport::Notifications`
@@ -5,7 +5,7 @@
5
5
  module Praxis::Mapper
6
6
  class IdentityMap
7
7
  include IdentityMapExtensions::Persistence
8
-
8
+
9
9
  class UnloadedRecordException < StandardError; end;
10
10
  class UnsupportedModel < StandardError; end;
11
11
  class UnknownIdentity < StandardError; end;
@@ -185,7 +185,20 @@ module Praxis::Mapper
185
185
  end
186
186
  end
187
187
 
188
- def finalize!(*models, instrument: true)
188
+ # Last parameter in array can be a hash of objects
189
+ # It is implemented this way (instead of (*models, instrument: true)) because when passing in
190
+ # Sequel models, ruby will invoke the ".to_hash" on them, causing a "load" when trying to restructure the args
191
+ def finalize!(*models_and_opts)
192
+
193
+ models, instrument = if models_and_opts.last.kind_of?(::Hash)
194
+ ins = models_and_opts.last.fetch(:instrument) do
195
+ true
196
+ end
197
+ [ models_and_opts[0..-2], ins ]
198
+ else
199
+ [ models_and_opts, true ]
200
+ end
201
+
189
202
  if instrument
190
203
  ActiveSupport::Notifications.instrument 'praxis.mapper.finalize' do
191
204
  _finalize!(*models)
@@ -349,7 +362,7 @@ module Praxis::Mapper
349
362
  value = values[0]
350
363
  if @row_keys[model].has_key?(key)
351
364
  res = @row_keys[model][key][value]
352
-
365
+
353
366
  if res
354
367
  [res]
355
368
  else
@@ -1,5 +1,5 @@
1
1
  module Praxis
2
2
  module Mapper
3
- VERSION = "4.1"
3
+ VERSION = "4.1.1"
4
4
  end
5
5
  end
@@ -304,6 +304,24 @@ describe Praxis::Mapper::IdentityMap do
304
304
  identity_map.finalize!(instrument: false)
305
305
  end
306
306
 
307
+ context 'plays well with Sequel models' do
308
+ # The reason to test agains Sequel models is that the destructuring of args
309
+ # for the _finalize! call caused unexpecting "loads" due to invoking .to_hash on them, see function for details
310
+ it 'calls the _finalize! with just the one model passed' do
311
+ identity_map.should_receive(:_finalize!).with(UserModel)
312
+ identity_map.finalize!(UserModel)
313
+ end
314
+
315
+ it 'calls the _finalize! with just the models passed' do
316
+ identity_map.should_receive(:_finalize!).with(UserModel,PostModel)
317
+ identity_map.finalize!(UserModel,PostModel)
318
+ end
319
+
320
+ it 'calls the _finalize! discarding instrument opts' do
321
+ identity_map.should_receive(:_finalize!).with(UserModel)
322
+ identity_map.finalize!(UserModel, instrument: false)
323
+ end
324
+ end
307
325
  end
308
326
 
309
327
  context "#finalize_model!" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: praxis-mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: '4.1'
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Blanquer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-18 00:00:00.000000000 Z
12
+ date: 2015-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: randexp
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  version: '0'
317
317
  requirements: []
318
318
  rubyforge_project:
319
- rubygems_version: 2.4.5.1
319
+ rubygems_version: 2.2.2
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: A multi-datastore library designed for efficiency in loading large datasets.