jit_preloader 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 9209e8e03dd7ebf7543435a61c98452f229b98ad
4
- data.tar.gz: 608e6a970d068893eb71fcc3ebba489e77663cd7
3
+ metadata.gz: 8dd36dd4639cc012aff19a8afdfb6bee699cdd1c
4
+ data.tar.gz: 41d7e22054a231edba2dc80ce3d19ac16e57cef9
5
5
  SHA512:
6
- metadata.gz: a88b2f6b198e0b72dd6e8bbaf68cc9b0a9397cadd6bc4e76f39ede7b959873a9ad185af56fb2681cf60a412b5b87b92c9fe6daf175f4ac4f7e98ede9b4c2e639
7
- data.tar.gz: f8b58d50d67bb629b068d388f67571e0be8de13934982d1c708fcfa8ea079f10c60ded555c09cdbc2f422e426ab38ae62865c4a144fda00ce91cea47ac5c5446
6
+ metadata.gz: 9cb4b5385ab0e3e7a321ac759372dbd6bd715141b89b92c82773c40f547bef92311bdfa365ad43a7b5d544c8983962f769d39a02949476fa660da305b59792d8
7
+ data.tar.gz: 5f24a4834a8bff484cdb849702ad71b62ddc10289134dbc1f6ad9431644015244a4ab252a6ddb74ac9d91ed47b9e1963af3cf2041fcd305e3eff0493cf1477b5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jit_preloader (0.0.1)
4
+ jit_preloader (0.0.3)
5
5
  activerecord (~> 4.2)
6
6
  activesupport
7
7
 
@@ -19,5 +19,19 @@ module JitPreloader
19
19
  preload records_with_association, association
20
20
  end
21
21
 
22
+ # We do not want the jit_preloader to be dumpable
23
+ # If you dump a ActiveRecord::Base object that has a jit_preloader instance variable
24
+ # you will also end up dumping all of the records the preloader has reference to.
25
+ # Imagine getting N objects from a query and dumping each one of those into a cache
26
+ # each object would dump N+1 objects which means you'll end up storing O(N^2) memory. Thats no good.
27
+ # So instead, we will just nullify the jit_preloader on load
28
+ def _dump(level)
29
+ ""
30
+ end
31
+
32
+ def self._load(args)
33
+ nil
34
+ end
35
+
22
36
  end
23
37
  end
@@ -1,3 +1,3 @@
1
1
  module JitPreloader
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -38,6 +38,19 @@ RSpec.describe JitPreloader::Preloader do
38
38
  ->(event, data){ source_map[data[:source]] << data[:association] }
39
39
  end
40
40
 
41
+ context "when we marshal dump the active record object" do
42
+ it "nullifes the jit_preloader reference" do
43
+ contacts = Contact.jit_preload.to_a
44
+ reloaded_contacts = contacts.collect{|r| Marshal.load(Marshal.dump(r)) }
45
+ contacts.each do |c|
46
+ expect(c.jit_preloader).to_not be_nil
47
+ end
48
+ reloaded_contacts.each do |c|
49
+ expect(c.jit_preloader).to be_nil
50
+ end
51
+ end
52
+ end
53
+
41
54
  context "when the preloader is globally enabled" do
42
55
  around do |example|
43
56
  JitPreloader.globally_enabled = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jit_preloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle d'Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord