jit_preloader 0.0.6 → 0.0.7

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: 7b508dc508f804374c434fdcb808594840b0bd1a
4
- data.tar.gz: e121854c6408c3d1423a1e272fe23fc7365a2d03
3
+ metadata.gz: 0d26d02e1483223dda866884820aec9f06532e4a
4
+ data.tar.gz: c0d4c36e1c7300030113a3ca1ba4dfb22681a062
5
5
  SHA512:
6
- metadata.gz: 4929e0d516ccf9056fbe4249127d9fcc599cfef7e62d0d3d684c121ff86fc4f7daef4454aed5e6cd36d9af4252457774c6a7c35bb3a3ef4d6215056ced005056
7
- data.tar.gz: a250cbb9ba56a7e9bb8e98b57b09ef02cc75ef7afb31add20c1ce9c1d00b08349048966a0c65df7c1c6edac78ef023f2d7b262e056c134ec84719532a5d6c707
6
+ metadata.gz: 897e6e6246d4568fdef1f34dbe29c37a54a64b0d1ff58ff4d2cdc3dae7a9765ecf87d99f94247624666cdd099549b5ceea864336333d9719130299147d7bc3d2
7
+ data.tar.gz: a0d912d630bf11b8a7071a0a7949713eb6f67578735d186a53b18eb8d1f36fe89a5d289c0662c498196120d78b0a58e04558497aba3c1a2794712c669ac6ac6a
@@ -5,7 +5,7 @@ module JitPreloader
5
5
 
6
6
  def self.attach(records)
7
7
  new.tap do |loader|
8
- loader.records = records
8
+ loader.records = records.dup
9
9
  records.each do |record|
10
10
  record.jit_preloader = loader
11
11
  end
@@ -21,7 +21,7 @@ module JitPreloader
21
21
 
22
22
  # We do not want the jit_preloader to be dumpable
23
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.
24
+ # you will also end up dumping all of the records the preloader has reference to.
25
25
  # Imagine getting N objects from a query and dumping each one of those into a cache
26
26
  # each object would dump N+1 objects which means you'll end up storing O(N^2) memory. Thats no good.
27
27
  # So instead, we will just nullify the jit_preloader on load
@@ -1,3 +1,3 @@
1
1
  module JitPreloader
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -93,6 +93,12 @@ RSpec.describe JitPreloader::Preloader do
93
93
  example.run
94
94
  JitPreloader.globally_enabled = false
95
95
  end
96
+ it "doesn't reference the same records array that is returned" do
97
+ contacts = Contact.all.to_a
98
+ contacts << "A string"
99
+ expect(contacts.first.jit_preloader.records).to eql Contact.all.to_a
100
+ end
101
+
96
102
  context "when grabbing all of the address'es contries and email addresses" do
97
103
  it "doesn't generate an N+1 query ntoification" do
98
104
  ActiveSupport::Notifications.subscribed(callback, "n_plus_one_query") do
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.6
4
+ version: 0.0.7
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: 2017-01-27 00:00:00.000000000 Z
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  requirements: []
175
175
  rubyforge_project:
176
- rubygems_version: 2.4.8
176
+ rubygems_version: 2.5.2
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: Tool to understand N+1 queries and to remove them