blueprinter-activerecord 1.0.0 → 1.0.2

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: 65c4c6d27e0bea2ed2d73f35949587cf6f2197cd540fe2a1ceef1a49d2d135d8
4
- data.tar.gz: 850d61584f87c743478d496ce1117cdd2bda7b6db7d92a582cb875f7d63c4f70
3
+ metadata.gz: 7bec64f8859b0d2cea3346675d4b2a3279245bcb5f7060b0ba0bfcf2f3bb4d83
4
+ data.tar.gz: 4fe808fc8be1d043bc18d53dbe3e6a02c40904408ed51f6a8d0fbe0fc1349b2f
5
5
  SHA512:
6
- metadata.gz: 40c750e1e67710a3e695a495be6702393f6f72f145ebf47cc21d78587c34cb14ae899edb4cb76a31c599bdb075b5f93c490ff7eb7f5ddc9d16bf15e22314f544
7
- data.tar.gz: 531d150f3cc8aa474d8c149ae35663395cf0893e406953cf0174cd06fc77ff92f8c7c1cd4ccbaa63a054b7ba930fcb92efd4bf501c6323e1f6033d8a40787053
6
+ metadata.gz: 3f20ed5466369e302e0e8d73bae2bade4fa92cd7efa6ae2bba63eb49494af7990cbc74d371f6c7f4efe782a94ae4d001fbc2dfdbce7a2358771ce6fdc748442c
7
+ data.tar.gz: 86b01a869b55e52ac6cfbac55dacb149112a01409ec004d7c55e4ef79451d5716327aa4aa04b8777aef2d68e000498d66f04c813e25d098ad985948bc103ad77
@@ -28,16 +28,17 @@ module BlueprinterActiveRecord
28
28
 
29
29
  #
30
30
  # Implements the "pre_render" Blueprinter Extension to preload associations from a view.
31
- # If auto is true, all ActiveRecord::Relation objects will be preloaded. If auto is false,
32
- # only queries that have called `.preload_blueprint` will be preloaded.
31
+ # If auto is true, all ActiveRecord::Relation and ActiveRecord::AssociationRelation objects
32
+ # will be preloaded. If auto is false, only queries that have called `.preload_blueprint`
33
+ # will be preloaded.
33
34
  #
34
35
  # NOTE: If auto is on, *don't* be concerned that you'll end up with duplicate preloads. Even if
35
36
  # the query ends up with overlapping members in 'preload' and 'includes', ActiveRecord
36
37
  # intelligently handles them. There are several unit tests which confirm this behavior.
37
38
  #
38
39
  def pre_render(object, blueprint, view, options)
39
- case object
40
- when ActiveRecord::Relation
40
+ case object.class.name
41
+ when "ActiveRecord::Relation", "ActiveRecord::AssociationRelation"
41
42
  if object.preload_blueprint_method || auto || auto_proc&.call(object, blueprint, view, options) == true
42
43
  object.before_preload_blueprint = extract_preloads object
43
44
  blueprint_preloads = self.class.preloads(blueprint, view, object.model)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlueprinterActiveRecord
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprinter-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Procore Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-09 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: '2.7'
151
+ version: '3.0'
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="
@@ -158,5 +158,5 @@ requirements: []
158
158
  rubygems_version: 3.4.19
159
159
  signing_key:
160
160
  specification_version: 4
161
- summary: Extensions for using ActiveRecord with ActiveRecord
161
+ summary: Extensions for using Blueprinter with ActiveRecord
162
162
  test_files: []