ams_lazy_relationships 0.1.2 → 0.1.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: 9e130952b9f88604a3afccc0cacd41fb9581fc61
4
- data.tar.gz: cbf67a43c13d79ab78292b82e8ebefd9b30906b1
3
+ metadata.gz: 8f2d4206f5ac6fe534e19162405e4d6993e5a8ea
4
+ data.tar.gz: 78c94b7d3b54794b4ce8dd7f9b5645e694f2eff7
5
5
  SHA512:
6
- metadata.gz: 940c44cb36ba0c751e1090f6a2a9d7c032752a67ae33fb5967062e78a42d50e3f152dc54a46636f6ce33a2a29d703989c83ba1630a32ea13d1ce73c81648a9c6
7
- data.tar.gz: 77a3f4a94552a0229732e13abc9c950e57a67cf17b7c6095429ad16d2a3c6410863f3b0e0a342e5224b30f0793faec3597512e0259d51e76254942d97b4acd5f
6
+ metadata.gz: 80230d616e3b5007577ca2053080a1f11eda4d7b2978dd30ebb56d79819e5bd6555668add82b446cf381b00fc5684bf63bc13cb70085e2d818ba7d1d072ec228
7
+ data.tar.gz: c79403dd23812c678235b63a207e218c2c72eda850c7635fe0d962b536305a69c8188d85449e3f07a409702c22db9b573781f9ae6e6a172eaf2bed126fcaf101
@@ -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)*
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ams_lazy_relationships (0.1.2)
4
+ ams_lazy_relationships (0.1.3)
5
5
  active_model_serializers
6
6
  batch-loader (~> 1.2)
7
7
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AmsLazyRelationships
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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.2
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-03-10 00:00:00.000000000 Z
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: