ams_lazy_relationships 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/Gemfile.lock +1 -1
- data/ams_lazy_relationships.gemspec +1 -1
- data/lib/ams_lazy_relationships/loaders/association.rb +4 -14
- data/lib/ams_lazy_relationships/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f2d4206f5ac6fe534e19162405e4d6993e5a8ea
|
4
|
+
data.tar.gz: 78c94b7d3b54794b4ce8dd7f9b5645e694f2eff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80230d616e3b5007577ca2053080a1f11eda4d7b2978dd30ebb56d79819e5bd6555668add82b446cf381b00fc5684bf63bc13cb70085e2d818ba7d1d072ec228
|
7
|
+
data.tar.gz: c79403dd23812c678235b63a207e218c2c72eda850c7635fe0d962b536305a69c8188d85449e3f07a409702c22db9b573781f9ae6e6a172eaf2bed126fcaf101
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.1.3](https://github.com/Bajena/ams_lazy_relationships/tree/v0.1.3) (2019-05-19)
|
4
|
+
[Full Changelog](https://github.com/Bajena/ams_lazy_relationships/compare/0.1.2...v0.1.3)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Association loader shouldn't yield cached associations data instantly [\#22](https://github.com/Bajena/ams_lazy_relationships/issues/22)
|
9
|
+
- Customize loading behavior [\#14](https://github.com/Bajena/ams_lazy_relationships/issues/14)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Do not yield cached associations data instantly in Association loader [\#23](https://github.com/Bajena/ams_lazy_relationships/pull/23) ([Bajena](https://github.com/Bajena))
|
14
|
+
|
3
15
|
## [0.1.2](https://github.com/Bajena/ams_lazy_relationships/tree/0.1.2) (2019-03-10)
|
4
16
|
[Full Changelog](https://github.com/Bajena/ams_lazy_relationships/compare/v0.1.1...0.1.2)
|
5
17
|
|
@@ -41,4 +53,4 @@
|
|
41
53
|
|
42
54
|
|
43
55
|
|
44
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
56
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile.lock
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
if spec.respond_to?(:metadata)
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
20
|
spec.metadata["source_code_uri"] = "https://github.com/Bajena/ams_lazy_relationships"
|
21
|
-
spec.metadata["changelog_uri"] = "https://github.com/Bajena/ams_lazy_relationships/CHANGELOG.md"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/Bajena/ams_lazy_relationships/blob/master/CHANGELOG.md"
|
22
22
|
else
|
23
23
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
24
24
|
"public gem pushes."
|
@@ -20,20 +20,6 @@ module AmsLazyRelationships
|
|
20
20
|
# @param block [Proc] a block to execute when data is evaluated.
|
21
21
|
# Loaded data is yielded as a block argument.
|
22
22
|
def load(record, &block)
|
23
|
-
if record.association(association_name.to_sym).loaded?
|
24
|
-
data = record.public_send(association_name)
|
25
|
-
block&.call(Array.wrap(data).compact.uniq)
|
26
|
-
return data
|
27
|
-
end
|
28
|
-
|
29
|
-
lazy_load(record, block)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
attr_reader :model_class_name, :association_name
|
35
|
-
|
36
|
-
def lazy_load(record, block)
|
37
23
|
BatchLoader.for(record).batch(key: batch_key) do |records, loader|
|
38
24
|
data = load_data(records, loader)
|
39
25
|
|
@@ -41,6 +27,10 @@ module AmsLazyRelationships
|
|
41
27
|
end
|
42
28
|
end
|
43
29
|
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :model_class_name, :association_name
|
33
|
+
|
44
34
|
def load_data(records, loader)
|
45
35
|
# It may happen that same record comes here twice (e.g. wrapped
|
46
36
|
# in a decorator and non-wrapped). In this case Associations::Preloader
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ams_lazy_relationships
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Bajena
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -320,7 +320,7 @@ licenses:
|
|
320
320
|
metadata:
|
321
321
|
homepage_uri: https://github.com/Bajena/ams_lazy_relationships
|
322
322
|
source_code_uri: https://github.com/Bajena/ams_lazy_relationships
|
323
|
-
changelog_uri: https://github.com/Bajena/ams_lazy_relationships/CHANGELOG.md
|
323
|
+
changelog_uri: https://github.com/Bajena/ams_lazy_relationships/blob/master/CHANGELOG.md
|
324
324
|
post_install_message:
|
325
325
|
rdoc_options: []
|
326
326
|
require_paths:
|