blueprinter 0.23.4 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -4
- data/README.md +20 -0
- data/lib/blueprinter/extractors/association_extractor.rb +2 -0
- 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: 2d5e6d18d1ccf85eebe25b2aef41b629fbdad10a2972684e458bfbf268f266f0
|
4
|
+
data.tar.gz: a60400a4b58cb8d26db31838b8da490096b747d17b3912e119db413796d9f5ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c58a220d1187a9fa39514158b7e585576010b030da4430a41263ea4dc47f43d1a115e4b475230dfc4a995e1607f870b280d26182d012109013b3303fd75d7cd
|
7
|
+
data.tar.gz: a9a8380551402f4aace847aa1333269e4e2d6052dcf220ea94dbe8f2976a7abb6172558926417438085ca56f57ca744d6a94f1694380ab44c98df37aba9751c3
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
+
## 0.24.0 - 2020/6/22
|
2
|
+
* 🚀 [FEATURE] Add an `options` option to associations to facilitate passing options from one blueprint to another. [#220](https://github.com/procore/blueprinter/pull/220). Thanks to [@mcclayton](https://github.com/mcclayton).
|
3
|
+
|
1
4
|
## 0.23.4 - 2020/4/28
|
2
5
|
* 🚀 [FEATURE] Public class method `has_view?` on Blueprinter::Base subclasses introduced in [#213](https://github.com/procore/blueprinter/pull/213). Thanks to [@spencerneste](https://github.com/spencerneste).
|
3
6
|
|
4
|
-
## 0.23.3 -
|
7
|
+
## 0.23.3 - 2020/4/7
|
5
8
|
* 🐛 [BUGFIX] Fixes issue where `exclude` fields in deeply nested views were not respected. Resolved issue [207](https://github.com/procore/blueprinter/issues/207) in [#208](https://github.com/procore/blueprinter/pull/208) by [@tpltn](https://github.com/tpltn).
|
6
9
|
|
7
|
-
## 0.23.2 -
|
10
|
+
## 0.23.2 - 2020/3/16
|
8
11
|
* 🐛 [BUGFIX] Fixes issue where fields "bled" into other views due to merge side-effects. Resolved issue [205](https://github.com/procore/blueprinter/issues/205) in [#204](https://github.com/procore/blueprinter/pull/204) by [@trevorrjohn](https://github.com/trevorrjohn).
|
9
12
|
|
10
|
-
## 0.23.1 -
|
13
|
+
## 0.23.1 - 2020/3/13
|
11
14
|
* 🐛 [BUGFIX] Fixes #172 where views would unintentionally ignore `sort_fields_by: :definition` configuration. Resolved in [#197](https://github.com/procore/blueprinter/pull/197) by [@wlkrw](https://github.com/wlkrw).
|
12
15
|
|
13
|
-
## 0.23.0 -
|
16
|
+
## 0.23.0 - 2020/1/31
|
14
17
|
* 🚀 [FEATURE] Configurable default extractor introduced in [#198](https://github.com/procore/blueprinter/pull/198) by [@wlkrw](https://github.com/wlkrw). You can now set a default extractor like so:
|
15
18
|
```
|
16
19
|
Blueprinter.configure do |config|
|
data/README.md
CHANGED
@@ -355,6 +355,26 @@ Output:
|
|
355
355
|
}
|
356
356
|
```
|
357
357
|
|
358
|
+
It is also possible to pass options from one Blueprint to another via an association.
|
359
|
+
For example:
|
360
|
+
```ruby
|
361
|
+
class VehicleBlueprint < Blueprinter::Base
|
362
|
+
identifier :uuid
|
363
|
+
field :full_name do |vehicle, options|
|
364
|
+
"#{vehicle.model} #{options[:trim]}"
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
class DriverBlueprint < Blueprinter::Base
|
369
|
+
identifier :uuid
|
370
|
+
|
371
|
+
view :normal do
|
372
|
+
fields :first_name, :last_name
|
373
|
+
association :vehicles, blueprint: vehicle_blueprint, options: { trim: 'LX' }
|
374
|
+
end
|
375
|
+
end
|
376
|
+
```
|
377
|
+
|
358
378
|
---
|
359
379
|
</details>
|
360
380
|
|
@@ -9,6 +9,8 @@ module Blueprinter
|
|
9
9
|
|
10
10
|
def extract(association_name, object, local_options, options={})
|
11
11
|
options_without_default = options.reject { |k,_| k == :default || k == :default_if }
|
12
|
+
# Merge in assocation options hash
|
13
|
+
local_options = local_options.merge(options[:options]) if options[:options].is_a?(Hash)
|
12
14
|
value = @extractor.extract(association_name, object, local_options, options_without_default)
|
13
15
|
return default_value(options) if use_default_value?(value, options[:default_if])
|
14
16
|
view = options[:view] || :default
|
data/lib/blueprinter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueprinter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hess
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: factory_bot
|