jit_preloader 0.0.5 → 0.0.6

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: 8b6500123613b4cac00d676d731cb65eb59ce847
4
- data.tar.gz: 940e041e05f643ee35ca43bd192ade9c1a5b5857
3
+ metadata.gz: 7b508dc508f804374c434fdcb808594840b0bd1a
4
+ data.tar.gz: e121854c6408c3d1423a1e272fe23fc7365a2d03
5
5
  SHA512:
6
- metadata.gz: 425c551f3a1daf7c21120cb9290b294dc4cb9f0d17b6b0b614ab3d13fafdedb793229cbdcf0dc1e337e5f5b05f1e36d476347a94b5c855dfee0303a97b36083e
7
- data.tar.gz: 06ca2ebee6226d8d51ef465c4e2a5bde86ad9231a1f5d6249a3681f74f9830946886e1716f0b76b85709ed946ca09b9087b5165a1b3ac4ce06a568a4386731a0
6
+ metadata.gz: 4929e0d516ccf9056fbe4249127d9fcc599cfef7e62d0d3d684c121ff86fc4f7daef4454aed5e6cd36d9af4252457774c6a7c35bb3a3ef4d6215056ced005056
7
+ data.tar.gz: a250cbb9ba56a7e9bb8e98b57b09ef02cc75ef7afb31add20c1ce9c1d00b08349048966a0c65df7c1c6edac78ef023f2d7b262e056c134ec84719532a5d6c707
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jit_preloader (0.0.3)
4
+ jit_preloader (0.0.6)
5
5
  activerecord (~> 4.2)
6
6
  activesupport
7
7
 
@@ -28,7 +28,7 @@ GEM
28
28
  diff-lcs (1.2.5)
29
29
  i18n (0.7.0)
30
30
  json (1.8.3)
31
- minitest (5.9.1)
31
+ minitest (5.10.1)
32
32
  rake (10.5.0)
33
33
  rspec (3.5.0)
34
34
  rspec-core (~> 3.5.0)
@@ -59,3 +59,6 @@ DEPENDENCIES
59
59
  rake (~> 10.0)
60
60
  rspec
61
61
  sqlite3
62
+
63
+ BUNDLED WITH
64
+ 1.13.6
data/README.md CHANGED
@@ -159,7 +159,7 @@ end
159
159
  #new
160
160
  class Contact < ActiveRecord::Bas
161
161
  has_many :addresses
162
- has_many_aggregate :addresses, :max_street_length, :maximum, "LENGTH(street)"
162
+ has_many_aggregate :addresses, :max_street_length, :maximum, "LENGTH(street)", default: nil
163
163
  has_many_aggregate :addresses, :count_all, :count, "*"
164
164
  end
165
165
 
@@ -17,13 +17,16 @@ module JitPreloadExtension
17
17
  define_method(method_name) do
18
18
  self.jit_preload_aggregates ||= {}
19
19
 
20
- return jit_preload_aggregates[method_name] if jit_preload_aggregates[method_name]
20
+ return jit_preload_aggregates[method_name] if jit_preload_aggregates.key?(method_name)
21
21
  if jit_preloader
22
22
  reflection = association(assoc).reflection
23
23
  primary_ids = jit_preloader.records.collect{|r| r[reflection.active_record_primary_key] }
24
24
  klass = reflection.klass
25
25
 
26
- preloaded_data = Hash[klass
26
+ association_scope = klass
27
+ association_scope = association_scope.instance_exec(&reflection.scope).reorder(nil) if reflection.scope
28
+
29
+ preloaded_data = Hash[association_scope
27
30
  .where(reflection.foreign_key => primary_ids)
28
31
  .group(reflection.foreign_key)
29
32
  .send(aggregate, field)
@@ -1,3 +1,3 @@
1
1
  module JitPreloader
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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.5
4
+ version: 0.0.6
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-20 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord