blueprinter 1.1.0 → 1.1.1

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
  SHA256:
3
- metadata.gz: c9d38943f08cbd1ded61e894b8b3360ec2e0948f8fa87a1fe4cb789d740a99d5
4
- data.tar.gz: c17c2f18caafe392da5f6e8aeee5efa3bf238a1b16e081de7db6f783fd84ac1c
3
+ metadata.gz: d6126b25a4c6b88be36bd59b5bf18c6fa9fcc7f33815fb78679eab249e1b7992
4
+ data.tar.gz: a29d92d2db99389c97d55235cc1f762bacc0b9841909f2ad3413013874546a9c
5
5
  SHA512:
6
- metadata.gz: 44975112b64d2c569299fdf06a30012c44560eaf2f774de9ff595291af9de34178baa6f393367224ffa1c7ae20568a5085eb8c9754e67f9af98bb82d1ce6d28a
7
- data.tar.gz: ccbc9b45404a7a30a3dae41505bf6759b3032d839139b1b0a3f15ca0b9d565a742fb26f770d55049528264fb4154978e39557b459668b2080bc8678379c4526d
6
+ metadata.gz: ab403215f43e966541dfc40b18a992fc713e1e490a6c03e304554f9e79416618333d44c1ae6bc2efbe1a30812bd36c23e64c43ce9877a1a573564bde7bff2b5f
7
+ data.tar.gz: aac7c74b4611e4ae5952d224365a7f0184e056aca8a0ec6431c3518370408fec6cc7d9ba55889c2504912edadb33e69935bb62f152f50d337e117bd10a762110
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.1 - 2024/10/2
2
+ * 🐛 [BUGFIX] Fixes an issue when when calling `.render` multiple times on a Blueprint using the same `options` hash, which would result in the `options` changing unexpectedly between calls. See [#453](https://github.com/procore-oss/blueprinter/pull/453). Thanks to [@ryanmccarthypdx](https://github.com/ryanmccarthypdx).
3
+ * 🐛 [BUGFIX] Fixes an issue when passing in a `Symbol` (representing a method) to the `if:` condition on an association. The provided `Symbol` would be erroneously sent to the association's Blueprint, instead of the Blueprint in which the association was defined within. See [#464](https://github.com/procore-oss/blueprinter/pull/464). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
4
+
1
5
  ## 1.1.0 - 2024/08/02
2
6
  * [BREAKING] Drops support for Ruby 2.7. See [#402](https://github.com/procore-oss/blueprinter/pull/402). Thanks to [@jmeridth](https://github.com/jmeridth)
3
7
  * 🚜 [REFACTOR] Cleans up Blueprint validation logic and implements an `Association` class with a clearer interface. See [#414](https://github.com/procore-oss/blueprinter/pull/414). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
@@ -11,18 +11,19 @@ module Blueprinter
11
11
  # @param name [Symbol] The name of the association as it will appear when rendered
12
12
  # @param blueprint [Blueprinter::Base] The blueprint to use for rendering the association
13
13
  # @param view [Symbol] The view to use in conjunction with the blueprint
14
+ # @param parent_blueprint [Blueprinter::Base] The blueprint that this association is being defined within
14
15
  # @param extractor [Blueprinter::Extractor] The extractor to use when retrieving the associated data
15
16
  # @param options [Hash]
16
17
  #
17
18
  # @return [Blueprinter::Association]
18
- def initialize(method:, name:, blueprint:, view:, extractor: AssociationExtractor.new, options: {})
19
+ def initialize(method:, name:, blueprint:, view:, parent_blueprint:, extractor: AssociationExtractor.new, options: {})
19
20
  BlueprintValidator.validate!(blueprint)
20
21
 
21
22
  super(
22
23
  method,
23
24
  name,
24
25
  extractor,
25
- blueprint,
26
+ parent_blueprint,
26
27
  options.merge(
27
28
  blueprint: blueprint,
28
29
  view: view,
@@ -153,11 +153,17 @@ module Blueprinter
153
153
 
154
154
  current_view << Association.new(
155
155
  method: method,
156
- name: options.delete(:name) || method,
157
- extractor: options.delete(:extractor) || AssociationExtractor.new,
158
- blueprint: options.delete(:blueprint),
159
- view: options.delete(:view) || :default,
160
- options: options.merge(block: block)
156
+ name: options.fetch(:name) { method },
157
+ extractor: options.fetch(:extractor) { AssociationExtractor.new },
158
+ blueprint: options.fetch(:blueprint),
159
+ parent_blueprint: self,
160
+ view: options.fetch(:view, :default),
161
+ options: options.except(
162
+ :name,
163
+ :extractor,
164
+ :blueprint,
165
+ :view
166
+ ).merge(block: block)
161
167
  )
162
168
  end
163
169
 
@@ -15,11 +15,21 @@ module Blueprinter
15
15
  private
16
16
 
17
17
  def prepare_for_render(object, options)
18
- view_name = options.delete(:view) || :default
19
- root = options.delete(:root)
20
- meta = options.delete(:meta)
18
+ view_name = options.fetch(:view, :default)
19
+ root = options[:root]
20
+ meta = options[:meta]
21
21
  validate_root_and_meta!(root, meta)
22
- prepare(object, view_name: view_name, local_options: options, root: root, meta: meta)
22
+ prepare(
23
+ object,
24
+ view_name: view_name,
25
+ local_options: options.except(
26
+ :view,
27
+ :root,
28
+ :meta
29
+ ),
30
+ root: root,
31
+ meta: meta
32
+ )
23
33
  end
24
34
 
25
35
  def prepare_data(object, view_name, local_options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Blueprinter
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
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-08-12 00:00:00.000000000 Z
11
+ date: 2024-10-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Blueprinter is a JSON Object Presenter for Ruby that takes business objects
14
14
  and breaks them down into simple hashes and serializes them to JSON. It can be used