auto_preload 0.1.0 → 0.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
  SHA256:
3
- metadata.gz: 27b495a7c7242a5cf7b8adbd58d4bd5b94b517f6c4328d0cd25ce9dd33108438
4
- data.tar.gz: dfa50abfe824c5a79ebfff08549e56e3fd9e84269a6f2bf4d7ac55885457ac99
3
+ metadata.gz: 5b400e79944285da53bdd3246948248bdef10323e536761b38794fa7c774a085
4
+ data.tar.gz: 222fcad81c801c6f33f1ae91e005b6402f87549b30e4f62d5e587b800e888f2d
5
5
  SHA512:
6
- metadata.gz: 1e499cdcc1ec269098a702eb824aa3f3a36d730b64867f74b359f5595d80e57f617942ad0decabf717baf1de01df2649b1a644ee4b521ecf22f9b4664a069692
7
- data.tar.gz: b13655e3b6423d98a2b6f26d6f91e7096be16c890a4a6449fda57e986959733d11d1f1a8cd5119dd4fcd9bff93f46d387a7bc16e4dd4b603754ab5162dbe2d8c
6
+ metadata.gz: 46b10d83dde0c430ff36e0a4a0ac49daab14426240c696a396e7687e762ebed642a06a7a0a97feb08707552f6723174837a99c36bcfb29b92206f262f9c45afe
7
+ data.tar.gz: 294bd08145cd0712de2899c2366b7e8c6783292cb837a1b397502410965cdb501e2c53198dcbd0a5814caecee87821be5d7b3cee9661193f0fc1cae3cca33e4a
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.1] - 2022-11-30
9
+
10
+ ### Fixed
11
+ - Prevent crash when passing a non-existing association
12
+
13
+ ## [0.1.0] - 2022-11-30
14
+
15
+ ### Added
16
+
17
+ - First release
@@ -7,21 +7,24 @@ module AutoPreload
7
7
  included do
8
8
  scope :auto_includes, lambda { |inclusions, options = {}|
9
9
  if inclusions.present?
10
- includes(*Resolver.new(options).resolve(self, inclusions))
10
+ resolved = Resolver.new(options).resolve(self, inclusions)
11
+ resolved.empty? ? self : includes(*resolved)
11
12
  else
12
13
  self
13
14
  end
14
15
  }
15
16
  scope :auto_preload, lambda { |inclusions, options = {}|
16
17
  if inclusions.present?
17
- preload(*Resolver.new(options).resolve(self, inclusions))
18
+ resolved = Resolver.new(options).resolve(self, inclusions)
19
+ resolved.empty? ? self : preload(*resolved)
18
20
  else
19
21
  self
20
22
  end
21
23
  }
22
24
  scope :auto_eager_load, lambda { |inclusions, options = {}|
23
25
  if inclusions.present?
24
- eager_load(*Resolver.new(options).resolve(self, inclusions))
26
+ resolved = Resolver.new(options).resolve(self, inclusions)
27
+ resolved.empty? ? self : eager_load(*resolved)
25
28
  else
26
29
  self
27
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AutoPreload
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_preload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mònade
@@ -64,6 +64,7 @@ files:
64
64
  - ".gitignore"
65
65
  - ".rspec"
66
66
  - ".rubocop.yml"
67
+ - CHANGELOG.md
67
68
  - Gemfile
68
69
  - LICENSE
69
70
  - README.md