blueprinter 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/blueprinter/association.rb +3 -2
- data/lib/blueprinter/base.rb +11 -5
- data/lib/blueprinter/helpers/base_helpers.rb +14 -4
- data/lib/blueprinter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6126b25a4c6b88be36bd59b5bf18c6fa9fcc7f33815fb78679eab249e1b7992
|
4
|
+
data.tar.gz: a29d92d2db99389c97d55235cc1f762bacc0b9841909f2ad3413013874546a9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
26
|
+
parent_blueprint,
|
26
27
|
options.merge(
|
27
28
|
blueprint: blueprint,
|
28
29
|
view: view,
|
data/lib/blueprinter/base.rb
CHANGED
@@ -153,11 +153,17 @@ module Blueprinter
|
|
153
153
|
|
154
154
|
current_view << Association.new(
|
155
155
|
method: method,
|
156
|
-
name: options.
|
157
|
-
extractor: options.
|
158
|
-
blueprint: options.
|
159
|
-
|
160
|
-
|
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.
|
19
|
-
root = options
|
20
|
-
meta = options
|
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(
|
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)
|
data/lib/blueprinter/version.rb
CHANGED
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.
|
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-
|
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
|