blueprinter 0.26.0 → 1.0.0

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: '084b38103a3fc3c3771e1c4c165ebc0886ffba618706e85550685b4009748b74'
4
- data.tar.gz: aa06eb341bd07f58fa3a7db984d6904baf368cd3825fdddaca8c95ce28d3c89c
3
+ metadata.gz: 0daefad3d40a1c147e4dff6ae392a0b36f344fac7b79b6a500bc39fbe50885bf
4
+ data.tar.gz: 41d4753399f53d94030ef650b7433399030ae282fe5e85124cee83f86b7558f3
5
5
  SHA512:
6
- metadata.gz: 453f3c4833925ff58aff5db8f5b6593a0d7c4cd60871996440ed832a55d15d9d00493c7b6cf8aeabbbdb66d3b23bd3c0ca83d66d44d7aff93c16478b15176509
7
- data.tar.gz: 7485797da5950803fec48384f950a8feb69880ed092e20db573b324484a600eb0898c80d0b311ceef5015b4e37a44f052b34f3867165b081258e1b95231acf31
6
+ metadata.gz: ff8384ffb0de03cfa91422313656a6e7ff9375b3335cdab1371e8a60db65a5cd9fbacaac1f32961c86e9bd213678cfdcd5911fc4a183962dbf57df8ff6155e54
7
+ data.tar.gz: f0cf694fd5984a274f8bfb2a664f7b6baa4406ee98a08a5666c2ccbf0e275627f3ed779e9770f3e6d506dc0b84eecb9ae3546846cd59819e93d1ea4676b63233
data/CHANGELOG.md CHANGED
@@ -1,35 +1,45 @@
1
+ ## 1.0.0 - 2024/01/17
2
+ * 🚀 [BREAKING] Allow transformers to be included across views. See [README](https://github.com/procore-oss/blueprinter#transform-across-views), PR [#372](https://github.com/procore-oss/blueprinter/pull/372) and issue [#225](https://github.com/procore-oss/blueprinter/issues/225) for details. Note this changes the behavior of transformers which were previously only applied to the view they were defined on. Thanks to [@njbbaer](https://github.com/njbbaer) and [@bhooshiek-narendiran](https://github.com/bhooshiek-narendiran).
3
+ * 🚀 [FEATURE] Introduce extension API, with initial support for pre_render hook. See [#358](https://github.com/procore-oss/blueprinter/pull/358) for details. Thanks to [@jhollinger](https://github.com/jhollinger).
4
+ * 💅 [ENHANCEMENT] Add reflection on views, fields, and associations. See PR [#357](https://github.com/procore-oss/blueprinter/pull/357), and issue [#341](https://github.com/procore-oss/blueprinter/issues/341) for details. Thanks to [@jhollinger](https://github.com/jhollinger).
5
+
6
+ ## 0.30.0 - 2023/09/16
7
+ * 🚀 [FEATURE] Allow configuring custom array-like classes to be treated as collections when serializing. More details can be found [here](https://github.com/procore-oss/blueprinter/pull/327). Thanks to [@toddnestor](https://github.com/toddnestor).
8
+ * 💅 [ENHANCEMENT] Reduce object allocations in fields calculations to save some memory. More details can be found [here](https://github.com/procore-oss/blueprinter/pull/327). Thanks to [@nametoolong](https://github.com/nametoolong).
9
+ * 💅 [ENHANCEMENT] Introduce rubocop
10
+ * 💅 [ENHANCEMENT] if/:unless procs with two arguments and invalid empty type deprecations are now removed
1
11
  ## 0.26.0 - 2023/08/17
2
12
  * 🐛 [BREAKING] Transition to GitHub Actions from CircleCI and update to handle Ruby versions 2.7, 3.0, 3.1, 3.2. Drop support for any ruby version less than 2.7. See [#307](https://github.com/procore-oss/blueprinter/pull/307)
3
13
 
4
14
  ## 0.25.3 - 2021/03/03
5
- * 🐛 [BUGFIX] Fixes issue where fields and associations that are redefined by later views were not properly overwritten. See [#201](https://github.com/procore/blueprinter/pull/201) thanks to [@Berardpi](https://github.com/Berardpi).
15
+ * 🐛 [BUGFIX] Fixes issue where fields and associations that are redefined by later views were not properly overwritten. See [#201](https://github.com/procore-oss/blueprinter/pull/201) thanks to [@Berardpi](https://github.com/Berardpi).
6
16
 
7
17
  ## 0.25.2 - 2020/11/19
8
- * 🚀 [FEATURE] Make deprecation behavior configurable (`:silence`, `:stderror`, `:raise`). See [#248](https://github.com/procore/blueprinter/pull/248) thanks to [@mcclayton](https://github.com/mcclayton).
18
+ * 🚀 [FEATURE] Make deprecation behavior configurable (`:silence`, `:stderror`, `:raise`). See [#248](https://github.com/procore-oss/blueprinter/pull/248) thanks to [@mcclayton](https://github.com/mcclayton).
9
19
 
10
20
  ## 0.25.1 - 2020/08/18
11
- * 🐛 [BUGFIX] Raise Blueprinter::BlueprinterError if Blueprint given is not of class Blueprinter::Base. Before it just raised a generic `undefined method 'prepare'`. See [#233](https://github.com/procore/blueprinter/pull/233) thanks to [@caws](https://github.com/caws).
21
+ * 🐛 [BUGFIX] Raise Blueprinter::BlueprinterError if Blueprint given is not of class Blueprinter::Base. Before it just raised a generic `undefined method 'prepare'`. See [#233](https://github.com/procore-oss/blueprinter/pull/233) thanks to [@caws](https://github.com/caws).
12
22
 
13
23
  ## 0.25.0 - 2020/07/06
14
- * 🚀 [FEATURE] Enable default `Blueprinter::Transformer`s to be set in the global configuration. [#222](https://github.com/procore/blueprinter/pull/222). Thanks to [@supremebeing7](https://github.com/supremebeing7).
24
+ * 🚀 [FEATURE] Enable default `Blueprinter::Transformer`s to be set in the global configuration. [#222](https://github.com/procore-oss/blueprinter/pull/222). Thanks to [@supremebeing7](https://github.com/supremebeing7).
15
25
 
16
26
  ## 0.24.0 - 2020/06/22
17
- * 🚀 [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).
27
+ * 🚀 [FEATURE] Add an `options` option to associations to facilitate passing options from one blueprint to another. [#220](https://github.com/procore-oss/blueprinter/pull/220). Thanks to [@mcclayton](https://github.com/mcclayton).
18
28
 
19
29
  ## 0.23.4 - 2020/04/28
20
- * 🚀 [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).
30
+ * 🚀 [FEATURE] Public class method `has_view?` on Blueprinter::Base subclasses introduced in [#213](https://github.com/procore-oss/blueprinter/pull/213). Thanks to [@spencerneste](https://github.com/spencerneste).
21
31
 
22
32
  ## 0.23.3 - 2020/04/07
23
- * 🐛 [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).
33
+ * 🐛 [BUGFIX] Fixes issue where `exclude` fields in deeply nested views were not respected. Resolved issue [207](https://github.com/procore-oss/blueprinter/issues/207) in [#208](https://github.com/procore-oss/blueprinter/pull/208) by [@tpltn](https://github.com/tpltn).
24
34
 
25
35
  ## 0.23.2 - 2020/03/16
26
- * 🐛 [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).
36
+ * 🐛 [BUGFIX] Fixes issue where fields "bled" into other views due to merge side-effects. Resolved issue [205](https://github.com/procore-oss/blueprinter/issues/205) in [#204](https://github.com/procore-oss/blueprinter/pull/204) by [@trevorrjohn](https://github.com/trevorrjohn).
27
37
 
28
38
  ## 0.23.1 - 2020/03/13
29
- * 🐛 [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).
39
+ * 🐛 [BUGFIX] Fixes #172 where views would unintentionally ignore `sort_fields_by: :definition` configuration. Resolved in [#197](https://github.com/procore-oss/blueprinter/pull/197) by [@wlkrw](https://github.com/wlkrw).
30
40
 
31
41
  ## 0.23.0 - 2020/01/31
32
- * 🚀 [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:
42
+ * 🚀 [FEATURE] Configurable default extractor introduced in [#198](https://github.com/procore-oss/blueprinter/pull/198) by [@wlkrw](https://github.com/wlkrw). You can now set a default extractor like so:
33
43
  ```
34
44
  Blueprinter.configure do |config|
35
45
  config.extractor_default = MyAutoExtractor
@@ -37,22 +47,22 @@ end
37
47
  ```
38
48
 
39
49
  ## 0.22.0 - 2019/12/26
40
- * 🚀 [FEATURE] Add rails generators. See `rails g blueprinter:blueprint --help` for usage. Introduced in [#176](https://github.com/procore/blueprinter/pull/176) by [@wlkrw](https://github.com/wlkrw).
50
+ * 🚀 [FEATURE] Add rails generators. See `rails g blueprinter:blueprint --help` for usage. Introduced in [#176](https://github.com/procore-oss/blueprinter/pull/176) by [@wlkrw](https://github.com/wlkrw).
41
51
 
42
52
  ## 0.21.0 - 2019/12/19
43
- * 🚀 [FEATURE] Ability to specify `default_if` field/association option for more control on when the default value is applied. [191](https://github.com/procore/blueprinter/pull/191). Thanks to [@mcclayton](https://github.com/mcclayton).
53
+ * 🚀 [FEATURE] Ability to specify `default_if` field/association option for more control on when the default value is applied. [191](https://github.com/procore-oss/blueprinter/pull/191). Thanks to [@mcclayton](https://github.com/mcclayton).
44
54
 
45
55
  ## 0.20.0 - 2019/10/15
46
- * 🚀 [FEATURE] Ability to include multiple views in a single method call with `include_views`. [184](https://github.com/procore/blueprinter/pull/184). Thanks to [@narendranvelmurugan](https://github.com/narendranvelmurugan).
56
+ * 🚀 [FEATURE] Ability to include multiple views in a single method call with `include_views`. [184](https://github.com/procore-oss/blueprinter/pull/184). Thanks to [@narendranvelmurugan](https://github.com/narendranvelmurugan).
47
57
 
48
- * 💅 [ENHANCEMENT] Update field-level conditional settings to reflect new three-argument syntax. [183](https://github.com/procore/blueprinter/pull/183). Thanks to [@danirod](https://github.com/danirod).
58
+ * 💅 [ENHANCEMENT] Update field-level conditional settings to reflect new three-argument syntax. [183](https://github.com/procore-oss/blueprinter/pull/183). Thanks to [@danirod](https://github.com/danirod).
49
59
 
50
- * 💅 [ENHANCEMENT] Modify Extractor access control in documentation. [182](https://github.com/procore/blueprinter/pull/182). Thanks to [@cagmz](https://github.com/cagmz).
60
+ * 💅 [ENHANCEMENT] Modify Extractor access control in documentation. [182](https://github.com/procore-oss/blueprinter/pull/182). Thanks to [@cagmz](https://github.com/cagmz).
51
61
 
52
- * 💅 [ENHANCEMENT] Fix the Transformer example documentation. [174](https://github.com/procore/blueprinter/pull/174). Thanks to [@tjwallace](https://github.com/tjwallace).
62
+ * 💅 [ENHANCEMENT] Fix the Transformer example documentation. [174](https://github.com/procore-oss/blueprinter/pull/174). Thanks to [@tjwallace](https://github.com/tjwallace).
53
63
 
54
64
  ## 0.19.0 - 2019/07/24
55
- * 🚀 [FEATURE] Added ability to specify transformers for Blueprinter views to further process the resulting hash before serialization. [#164](https://github.com/procore/blueprinter/pull/164). Thanks to [@amalarayfreshworks](https://github.com/amalarayfreshworks).
65
+ * 🚀 [FEATURE] Added ability to specify transformers for Blueprinter views to further process the resulting hash before serialization. [#164](https://github.com/procore-oss/blueprinter/pull/164). Thanks to [@amalarayfreshworks](https://github.com/amalarayfreshworks).
56
66
 
57
67
  ## 0.18.0 - 2019/05/29
58
68
 
@@ -60,83 +70,83 @@ end
60
70
  In order to be compliant with the the next major release, all conditional :if/:unless procs must be augmented to take in three arguments instead of two. i.e. `(obj, options)` to `(field_name, obj, options)`.
61
71
 
62
72
  ## 0.17.0 - 2019/05/23
63
- * 🐛 [BUGFIX] Fixing view: :identifier including non-identifier fields. [#154](https://github.com/procore/blueprinter/pull/154). Thanks to [@AllPurposeName](https://github.com/AllPurposeName).
73
+ * 🐛 [BUGFIX] Fixing view: :identifier including non-identifier fields. [#154](https://github.com/procore-oss/blueprinter/pull/154). Thanks to [@AllPurposeName](https://github.com/AllPurposeName).
64
74
 
65
- * 💅 [ENHANCEMENT] Add ability to override :extractor option for an ::association. [#152](https://github.com/procore/blueprinter/pull/152). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
75
+ * 💅 [ENHANCEMENT] Add ability to override :extractor option for an ::association. [#152](https://github.com/procore-oss/blueprinter/pull/152). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
66
76
 
67
77
  ## 0.16.0 - 2019/04/03
68
- * 🚀 [FEATURE] Add ability to exclude multiple fields inline using `excludes`. [#141](https://github.com/procore/blueprinter/pull/141). Thanks to [@pabhinaya](https://github.com/pabhinaya).
78
+ * 🚀 [FEATURE] Add ability to exclude multiple fields inline using `excludes`. [#141](https://github.com/procore-oss/blueprinter/pull/141). Thanks to [@pabhinaya](https://github.com/pabhinaya).
69
79
 
70
80
  ## 0.15.0 - 2019/04/01
71
- * 🚀 [FEATURE] Add ability to pass in `datetime_format` field option as either a string representing the strftime format, or a Proc which takes in the Date or DateTime object and returns the formatted date. [#145](https://github.com/procore/blueprinter/pull/145). Thanks to [@mcclayton](https://github.com/mcclayton).
81
+ * 🚀 [FEATURE] Add ability to pass in `datetime_format` field option as either a string representing the strftime format, or a Proc which takes in the Date or DateTime object and returns the formatted date. [#145](https://github.com/procore-oss/blueprinter/pull/145). Thanks to [@mcclayton](https://github.com/mcclayton).
72
82
 
73
83
  ## 0.14.0 - 2019/04/01
74
- * 🚀 [FEATURE] Added a global `datetime_format` option. [#135](https://github.com/procore/blueprinter/pull/143). Thanks to [@ritikesh](https://github.com/ritikesh).
84
+ * 🚀 [FEATURE] Added a global `datetime_format` option. [#135](https://github.com/procore-oss/blueprinter/pull/143). Thanks to [@ritikesh](https://github.com/ritikesh).
75
85
 
76
86
  ## 0.13.2 - 2019/03/14
77
- * 🐛 [BUGFIX] Replacing use of rails-specific method `Hash::except` so that Blueprinter continues to work in non-Rails environments. [#140](https://github.com/procore/blueprinter/pull/140). Thanks to [@checkbutton](https://github.com/checkbutton).
87
+ * 🐛 [BUGFIX] Replacing use of rails-specific method `Hash::except` so that Blueprinter continues to work in non-Rails environments. [#140](https://github.com/procore-oss/blueprinter/pull/140). Thanks to [@checkbutton](https://github.com/checkbutton).
78
88
 
79
89
  ## 0.13.1 - 2019/03/02
80
- * 💅 [MAINTENANCE | ENHANCEMENT] Cleaning up the `include_associations` section. This is not a documented/supported feature and is calling `respond_to?(:klass)` on every object passed to blueprinter. [#139](https://github.com/procore/blueprinter/pull/139). Thanks to [@ritikesh](https://github.com/ritikesh).
90
+ * 💅 [MAINTENANCE | ENHANCEMENT] Cleaning up the `include_associations` section. This is not a documented/supported feature and is calling `respond_to?(:klass)` on every object passed to blueprinter. [#139](https://github.com/procore-oss/blueprinter/pull/139). Thanks to [@ritikesh](https://github.com/ritikesh).
81
91
 
82
92
  ## 0.13.0 - 2019/02/07
83
93
 
84
- * 🚀 [FEATURE] Added an option to render with a root key. [#135](https://github.com/procore/blueprinter/pull/135). Thanks to [@ritikesh](https://github.com/ritikesh).
85
- * 🚀 [FEATURE] Added an option to render with a top-level meta attribute. [#135](https://github.com/procore/blueprinter/pull/135). Thanks to [@ritikesh](https://github.com/ritikesh).
94
+ * 🚀 [FEATURE] Added an option to render with a root key. [#135](https://github.com/procore-oss/blueprinter/pull/135). Thanks to [@ritikesh](https://github.com/ritikesh).
95
+ * 🚀 [FEATURE] Added an option to render with a top-level meta attribute. [#135](https://github.com/procore-oss/blueprinter/pull/135). Thanks to [@ritikesh](https://github.com/ritikesh).
86
96
 
87
97
  ## 0.12.1 - 2019/01/24
88
98
 
89
- * 🐛 [BUGFIX] Fix boolean `false` values getting serialized as `null`. Please see PR [#132](https://github.com/procore/blueprinter/pull/132). Thanks to [@samsongz](https://github.com/samsongz).
99
+ * 🐛 [BUGFIX] Fix boolean `false` values getting serialized as `null`. Please see PR [#132](https://github.com/procore-oss/blueprinter/pull/132). Thanks to [@samsongz](https://github.com/samsongz).
90
100
 
91
101
  ## 0.12.0 - 2019/01/16
92
102
 
93
- * 🚀 [FEATURE] Enables the setting of global `:field_default` and `:association_default` option value in the Blueprinter Configuration that will be used as default values for fields and associations that evaluate to nil. [#128](https://github.com/procore/blueprinter/pull/128). Thanks to [@mcclayton](https://github.com/mcclayton).
103
+ * 🚀 [FEATURE] Enables the setting of global `:field_default` and `:association_default` option value in the Blueprinter Configuration that will be used as default values for fields and associations that evaluate to nil. [#128](https://github.com/procore-oss/blueprinter/pull/128). Thanks to [@mcclayton](https://github.com/mcclayton).
94
104
 
95
105
  ## 0.11.0 - 2019/01/15
96
106
 
97
- * 🚀 [FEATURE] Enables the setting of a global `:if`/`:unless` proc in the Blueprinter Configuration that will be used to evaluate the conditional render of all fields. [#127](https://github.com/procore/blueprinter/pull/127). Thanks to [@mcclayton](https://github.com/mcclayton).
107
+ * 🚀 [FEATURE] Enables the setting of a global `:if`/`:unless` proc in the Blueprinter Configuration that will be used to evaluate the conditional render of all fields. [#127](https://github.com/procore-oss/blueprinter/pull/127). Thanks to [@mcclayton](https://github.com/mcclayton).
98
108
 
99
109
  ## 0.10.0 - 2018/12/20
100
110
 
101
- * 🚀 [FEATURE] Association Blueprints can be dynamically evaluated using a proc. [#122](https://github.com/procore/blueprinter/pull/122). Thanks to [@ritikesh](https://github.com/ritikesh).
111
+ * 🚀 [FEATURE] Association Blueprints can be dynamically evaluated using a proc. [#122](https://github.com/procore-oss/blueprinter/pull/122). Thanks to [@ritikesh](https://github.com/ritikesh).
102
112
 
103
113
  ## 0.9.0 - 2018/11/29
104
114
 
105
- * 🚀 [FEATURE] Added a `render_as_json` API. Similar to `render_as_hash` but returns a JSONified hash. Please see pr [#119](https://github.com/procore/blueprinter/pull/119). Thanks to [@ritikesh](https://github.com/ritikesh).
106
- * 🚀 [FEATURE] Sorting of fields in the response is now configurable to sort by definition or by name(asc only). Please see pr [#119](https://github.com/procore/blueprinter/pull/119). Thanks to [@ritikesh](https://github.com/ritikesh).
107
- * 💅 [ENHANCEMENT] Updated readme for above features and some existing undocumented features like `exclude fields`, `render_as_hash`. Please see pr [#119](https://github.com/procore/blueprinter/pull/119). Thanks to [@ritikesh](https://github.com/ritikesh).
115
+ * 🚀 [FEATURE] Added a `render_as_json` API. Similar to `render_as_hash` but returns a JSONified hash. Please see pr [#119](https://github.com/procore-oss/blueprinter/pull/119). Thanks to [@ritikesh](https://github.com/ritikesh).
116
+ * 🚀 [FEATURE] Sorting of fields in the response is now configurable to sort by definition or by name(asc only). Please see pr [#119](https://github.com/procore-oss/blueprinter/pull/119). Thanks to [@ritikesh](https://github.com/ritikesh).
117
+ * 💅 [ENHANCEMENT] Updated readme for above features and some existing undocumented features like `exclude fields`, `render_as_hash`. Please see pr [#119](https://github.com/procore-oss/blueprinter/pull/119). Thanks to [@ritikesh](https://github.com/ritikesh).
108
118
 
109
119
  ## 0.8.0 - 2018/11/19
110
120
 
111
- * 🚀 [FEATURE] Extend Support for other JSON encoders like yajl-ruby. Please see pr [#118](https://github.com/procore/blueprinter/pull/118). Thanks to [@ritikesh](https://github.com/ritikesh).
112
- * 🐛 [BUGFIX] Do not raise error on null date with `date_format` option. Please see pr [#117](https://github.com/procore/blueprinter/pull/117). Thanks to [@tpltn](https://github.com/tpltn).
113
- * 🚀 [FEATURE] Add `default` option to `field`s which will be used as the serialized value instead of `null` when the field evaluates to null. Please see pr [#115](https://github.com/procore/blueprinter/pull/115). Thanks to [@mcclayton](https://github.com/mcclayton).
114
- * 🐛 [BUGFIX] Made Base.associations completely private since they are not used outside of the Blueprinter base. Please see pr [#112](https://github.com/procore/blueprinter/pull/112). Thanks to [@philipqnguyen](https://github.com/philipqnguyen).
115
- * 🐛 [BUGFIX] Fix issue where entire Blueprinter module was marked api private. Please see pr [#111](https://github.com/procore/blueprinter/pull/111). Thanks to [@philipqnguyen](https://github.com/philipqnguyen).
116
- * 🚀 [FEATURE] Allow identifiers to be defined with a block. Please see pr [#110](https://github.com/procore/blueprinter/pull/110). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
117
- * 💅 [ENHANCEMENT] Update docs regarding the args yielded to blocks. Please see pr [#108](https://github.com/procore/blueprinter/pull/108). Thanks to [@philipqnguyen](https://github.com/philipqnguyen).
118
- * 💅 [ENHANCEMENT] Use `field` method in fields. Please see pr [#107](https://github.com/procore/blueprinter/pull/107). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
121
+ * 🚀 [FEATURE] Extend Support for other JSON encoders like yajl-ruby. Please see pr [#118](https://github.com/procore-oss/blueprinter/pull/118). Thanks to [@ritikesh](https://github.com/ritikesh).
122
+ * 🐛 [BUGFIX] Do not raise error on null date with `date_format` option. Please see pr [#117](https://github.com/procore-oss/blueprinter/pull/117). Thanks to [@tpltn](https://github.com/tpltn).
123
+ * 🚀 [FEATURE] Add `default` option to `field`s which will be used as the serialized value instead of `null` when the field evaluates to null. Please see pr [#115](https://github.com/procore-oss/blueprinter/pull/115). Thanks to [@mcclayton](https://github.com/mcclayton).
124
+ * 🐛 [BUGFIX] Made Base.associations completely private since they are not used outside of the Blueprinter base. Please see pr [#112](https://github.com/procore-oss/blueprinter/pull/112). Thanks to [@philipqnguyen](https://github.com/philipqnguyen).
125
+ * 🐛 [BUGFIX] Fix issue where entire Blueprinter module was marked api private. Please see pr [#111](https://github.com/procore-oss/blueprinter/pull/111). Thanks to [@philipqnguyen](https://github.com/philipqnguyen).
126
+ * 🚀 [FEATURE] Allow identifiers to be defined with a block. Please see pr [#110](https://github.com/procore-oss/blueprinter/pull/110). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
127
+ * 💅 [ENHANCEMENT] Update docs regarding the args yielded to blocks. Please see pr [#108](https://github.com/procore-oss/blueprinter/pull/108). Thanks to [@philipqnguyen](https://github.com/philipqnguyen).
128
+ * 💅 [ENHANCEMENT] Use `field` method in fields. Please see pr [#107](https://github.com/procore-oss/blueprinter/pull/107). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
119
129
 
120
130
  ## 0.7.0 - 2018/10/17
121
131
 
122
- * [FEATURE] Allow associations to be defined with a block. Please see pr [#106](https://github.com/procore/blueprinter/pull/106). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
123
- * [FEATURE] Inherit view definition when using inheritance. Please see pr [#105](https://github.com/procore/blueprinter/pull/105). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
132
+ * [FEATURE] Allow associations to be defined with a block. Please see pr [#106](https://github.com/procore-oss/blueprinter/pull/106). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
133
+ * [FEATURE] Inherit view definition when using inheritance. Please see pr [#105](https://github.com/procore-oss/blueprinter/pull/105). Thanks to [@hugopeixoto](https://github.com/hugopeixoto).
124
134
 
125
135
  ## 0.6.0 - 2018/06/05
126
136
 
127
137
  * 🚀 [FEATURE] Add `date_time` format as an option to `field`. Please see pr #68. Thanks to [@njbbaer](https://github.com/njbbaer).
128
- * 🚀 [FEATURE] Add conditional field support `:unless` and `:if` as an option to `field`. Please see pr [#86](https://github.com/procore/blueprinter/pull/86). Thanks to [@ojab](https://github.com/ojab).
129
- * 🐛 [BUGFIX] Fix case where miscellaneous options were not being passed through the `AutoExtractor`. See pr [#83](https://github.com/procore/blueprinter/pull/83).
138
+ * 🚀 [FEATURE] Add conditional field support `:unless` and `:if` as an option to `field`. Please see pr [#86](https://github.com/procore-oss/blueprinter/pull/86). Thanks to [@ojab](https://github.com/ojab).
139
+ * 🐛 [BUGFIX] Fix case where miscellaneous options were not being passed through the `AutoExtractor`. See pr [#83](https://github.com/procore-oss/blueprinter/pull/83).
130
140
 
131
141
  ## 0.5.0 - 2018/05/15
132
142
 
133
143
  * 🚀 [FEATURE] Add `default` option to `association` which will be used as the serialized value instead of `null` when the association evaluates to null.
134
- See PR [#78](https://github.com/procore/blueprinter/pull/78) by [@vinaya-procore](https://github.com/vinaya-procore).
144
+ See PR [#78](https://github.com/procore-oss/blueprinter/pull/78) by [@vinaya-procore](https://github.com/vinaya-procore).
135
145
 
136
146
  ## 0.4.0 - 2018/05/02
137
147
 
138
148
  * 🚀 [FEATURE] Add `render_as_hash` which will output a hash instead of
139
- a JSON String. See PR [#76](https://github.com/procore/blueprinter/pull/76) by [@amayer171](https://github.com/amayer171) and Issue [#73](https://github.com/procore/blueprinter/issues/73).
149
+ a JSON String. See PR [#76](https://github.com/procore-oss/blueprinter/pull/76) by [@amayer171](https://github.com/amayer171) and Issue [#73](https://github.com/procore-oss/blueprinter/issues/73).
140
150
 
141
151
  ## 0.3.0 - 2018/04/05
142
152
 
@@ -153,7 +163,7 @@ field(:first_name, extractor: CustomExtractor)
153
163
  ```
154
164
 
155
165
  * 💅 [ENHANCEMENT] Renamed Serializer classes to Extractor. See #72.
156
- * 💅 [ENHANCEMENT] Updated README. See pr [#66](https://github.com/procore/blueprinter/pull/66), [#65](https://github.com/procore/blueprinter/pull/65)
166
+ * 💅 [ENHANCEMENT] Updated README. See pr [#66](https://github.com/procore-oss/blueprinter/pull/66), [#65](https://github.com/procore-oss/blueprinter/pull/65)
157
167
 
158
168
  ## 0.2.0 - 2018/01/22
159
169
 
@@ -162,8 +172,8 @@ field(:first_name, extractor: CustomExtractor)
162
172
  association :comments, blueprint: CommentsBlueprint
163
173
  ```
164
174
 
165
- * 🐛 [BUGFIX] Remove Optimizer class. See [#61](https://github.com/procore/blueprinter/pull/61).
166
- * 🐛 [BUGFIX] Require associated objects to have a Blueprint, so that objects will always serialize properly. See [#60](https://github.com/procore/blueprinter/pull/60).
175
+ * 🐛 [BUGFIX] Remove Optimizer class. See [#61](https://github.com/procore-oss/blueprinter/pull/61).
176
+ * 🐛 [BUGFIX] Require associated objects to have a Blueprint, so that objects will always serialize properly. See [#60](https://github.com/procore-oss/blueprinter/pull/60).
167
177
 
168
178
  ## 0.1.0 - 2018/01/17
169
179
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Test](https://github.com/procore-oss/blueprinter/actions/workflows/test.yaml/badge.svg?branch=master)](https://github.com/procore-oss/blueprinter/actions/workflows/test.yaml)
2
2
  [![Gem Version](https://badge.fury.io/rb/blueprinter.svg)](https://badge.fury.io/rb/blueprinter)
3
- [![Gitter chat](https://badges.gitter.im/procore/blueprinter.svg)](https://gitter.im/blueprinter-gem/community)
3
+ [![Discord](https://img.shields.io/badge/Chat-EDEDED?logo=discord)](https://discord.gg/PbntEMmWws)
4
4
 
5
5
  <img src="blueprinter_logo.svg" width="25%">
6
6
 
@@ -33,8 +33,6 @@ Docs can be found [here](http://www.rubydoc.info/gems/blueprinter).
33
33
  <details open>
34
34
  <summary>Basic</summary>
35
35
 
36
- ---
37
-
38
36
  If you have an object you would like serialized, simply create a blueprint. Say, for example, you have a User record with the following attributes `[:uuid, :email, :first_name, :last_name, :password, :address]`.
39
37
 
40
38
  You may define a simple blueprint like so:
@@ -63,14 +61,11 @@ And the output would look like:
63
61
  "last_name": "Doe"
64
62
  }
65
63
  ```
66
-
67
- ---
68
64
  </details>
69
65
 
70
66
  <details>
71
67
  <summary>Collections</summary>
72
68
 
73
- ---
74
69
 
75
70
  You can also pass a collection object or an array to the render method.
76
71
 
@@ -97,13 +92,28 @@ This will result in JSON that looks something like this:
97
92
  ]
98
93
  ```
99
94
 
100
- ---
95
+
96
+ You can also configure other classes to be treated like collections. For example, if you are using Mongoid, you can configure it to treat `Mongoid::Criteria` objects as collections:
97
+
98
+ ```ruby
99
+ Blueprinter.configure do |config|
100
+ config.custom_array_like_classes = [Mongoid::Criteria]
101
+ end
102
+ ```
103
+
104
+ Or if you wanted it to treat the `Set` class as a collection:
105
+
106
+ ```ruby
107
+ Blueprinter.configure do |config|
108
+ config.custom_array_like_classes = [Set]
109
+ end
110
+ ```
111
+
101
112
  </details>
102
113
 
103
114
  <details>
104
115
  <summary>Renaming</summary>
105
116
 
106
- ---
107
117
 
108
118
  You can rename the resulting JSON keys in both fields and associations by using the `name` option.
109
119
 
@@ -127,13 +137,11 @@ This will result in JSON that looks something like this:
127
137
  }
128
138
  ```
129
139
 
130
- ---
131
140
  </details>
132
141
 
133
142
  <details>
134
143
  <summary>Views</summary>
135
144
 
136
- ---
137
145
 
138
146
  You may define different outputs by utilizing views:
139
147
 
@@ -174,13 +182,11 @@ Output:
174
182
  }
175
183
  ```
176
184
 
177
- ---
178
185
  </details>
179
186
 
180
187
  <details>
181
188
  <summary>Identifiers</summary>
182
189
 
183
- ---
184
190
 
185
191
  `identifier`s are used to specify a field or method name used as an identifier. Usually, this is something like `:id`.
186
192
 
@@ -199,14 +205,12 @@ Blueprinter `identifier`s have a few properties that set them apart from `field`
199
205
 
200
206
  If either of the above two developer conveniences are not desired, you can simply create your identifier fields as regular `field`s.
201
207
 
202
- ---
203
208
 
204
209
  </details>
205
210
 
206
211
  <details>
207
212
  <summary>Root</summary>
208
213
  <a name="root"></a>
209
- ---
210
214
 
211
215
  You can also optionally pass in a root key to wrap your resulting json in:
212
216
 
@@ -240,13 +244,11 @@ Output:
240
244
  }
241
245
  ```
242
246
 
243
- ---
244
247
  </details>
245
248
 
246
249
  <details>
247
250
  <summary>Meta Attributes</summary>
248
251
 
249
- ---
250
252
 
251
253
  You can additionally add meta-data to the json as well:
252
254
 
@@ -292,13 +294,11 @@ Output:
292
294
 
293
295
  _NOTE:_ For meta attributes, a [root](#root) is mandatory.
294
296
 
295
- ---
296
297
  </details>
297
298
 
298
299
  <details>
299
300
  <summary>Exclude Fields</summary>
300
301
 
301
- ---
302
302
 
303
303
  You can specifically choose to exclude certain fields for specific views
304
304
 
@@ -355,13 +355,11 @@ class UserBlueprint < Blueprinter::Base
355
355
  end
356
356
  ```
357
357
 
358
- ---
359
358
  </details>
360
359
 
361
360
  <details>
362
361
  <summary>Associations</summary>
363
362
 
364
- ---
365
363
 
366
364
  You may include associated objects. Say for example, a user has projects:
367
365
 
@@ -430,13 +428,11 @@ class DriverBlueprint < Blueprinter::Base
430
428
  end
431
429
  ```
432
430
 
433
- ---
434
431
  </details>
435
432
 
436
433
  <details>
437
434
  <summary>Default Association/Field Option</summary>
438
435
 
439
- ---
440
436
 
441
437
  By default, an association or field that evaluates to `nil` is serialized as `nil`. A default serialized value can be specified as an option on the association or field for cases when the association/field could potentially evaluate to `nil`. You can also specify a global `field_default` or `association_default` in the Blueprinter config which will be used for all fields/associations that evaluate to nil.
442
438
 
@@ -462,13 +458,11 @@ class UserBlueprint < Blueprinter::Base
462
458
  end
463
459
  ```
464
460
 
465
- ---
466
461
  </details>
467
462
 
468
463
  <details>
469
464
  <summary>default_if</summary>
470
465
 
471
- ---
472
466
 
473
467
  Sometimes, you may want certain "empty" values to pass through to the default value.
474
468
  Blueprinter provides the ability to treat the following empty types as the default value (or `nil` if no default provided).
@@ -500,13 +494,11 @@ class UserBlueprint < Blueprinter::Base
500
494
  end
501
495
  ```
502
496
 
503
- ---
504
497
  </details>
505
498
 
506
499
  <details>
507
500
  <summary>Supporting Dynamic Blueprints For Associations</summary>
508
501
 
509
- ---
510
502
 
511
503
  When defining an association, we can dynamically evaluate the blueprint. This comes in handy when adding polymorphic associations, by allowing reuse of existing blueprints.
512
504
 
@@ -535,13 +527,11 @@ end
535
527
 
536
528
  _NOTE:_ `taskable.blueprint` should return a valid Blueprint class. Currently, `has_many` is not supported because of the very nature of polymorphic associations.
537
529
 
538
- ---
539
530
  </details>
540
531
 
541
532
  <details>
542
533
  <summary>Defining A Field Directly In The Blueprint</summary>
543
534
 
544
- ---
545
535
 
546
536
  You can define a field directly in the Blueprint by passing it a block. This is especially useful if the object does not already have such an attribute or method defined, and you want to define it specifically for use with the Blueprint. This is done by passing `field` a block. The block also yields the object and any options that were passed from `render`. For example:
547
537
 
@@ -569,13 +559,11 @@ Output:
569
559
  }
570
560
  ```
571
561
 
572
- ---
573
562
  </details>
574
563
 
575
564
  <details>
576
565
  <summary>Defining An Identifier Directly In The Blueprint</summary>
577
566
 
578
- ---
579
567
 
580
568
  You can also pass a block to an identifier:
581
569
 
@@ -601,13 +589,11 @@ Output:
601
589
  }
602
590
  ```
603
591
 
604
- ---
605
592
  </details>
606
593
 
607
594
  <details>
608
595
  <summary>Defining An Association Directly In The Blueprint</summary>
609
596
 
610
- ---
611
597
 
612
598
  You can also pass a block to an association:
613
599
 
@@ -645,13 +631,11 @@ Output:
645
631
  }
646
632
  ```
647
633
 
648
- ---
649
634
  </details>
650
635
 
651
636
  <details>
652
637
  <summary>Passing Additional Properties To #render</summary>
653
638
 
654
- ---
655
639
 
656
640
  `render` takes an options hash which you can pass additional properties, allowing you to utilize those additional properties in the `field` block. For example:
657
641
 
@@ -679,13 +663,11 @@ Output:
679
663
  }
680
664
  ```
681
665
 
682
- ---
683
666
  </details>
684
667
 
685
668
  <details>
686
669
  <summary>Conditional Fields</summary>
687
670
 
688
- ---
689
671
 
690
672
  Both the `field` and the global Blueprinter Configuration supports `:if` and `:unless` options that can be used to serialize fields conditionally.
691
673
 
@@ -710,13 +692,11 @@ end
710
692
 
711
693
  _NOTE:_ The field-level setting overrides the global config setting (for the field) if both are set.
712
694
 
713
- ---
714
695
  </details>
715
696
 
716
697
  <details>
717
698
  <summary>Custom Formatting for Dates and Times</summary>
718
699
 
719
- ---
720
700
 
721
701
  To define a custom format for a Date or DateTime field, include the option `datetime_format`.
722
702
  This global or field-level option can be either a string representing the associated `strftime` format,
@@ -774,20 +754,18 @@ Output:
774
754
 
775
755
  _NOTE:_ The field-level setting overrides the global config setting (for the field) if both are set.
776
756
 
777
- ---
778
757
  </details>
779
758
 
780
759
  <details>
781
760
  <summary>Transform Classes</summary>
782
761
 
783
- ---
784
762
 
785
763
  Blueprinter provides the ability to specify `transform`s on views, which enable further
786
764
  processing and transforming of resulting view field hashes prior to serialization.
787
765
 
788
766
  Use `transform` to specify one transformer to be included for serialization.
789
767
  A transformer is a class, extending `Blueprinter::Transformer` and implementing the `transform` method.
790
- Whatever is returned from this `transform` method will end up being the resulting hash passed to serialization.
768
+ The modified `hash` object will be the resulting hash passed to serialization.
791
769
 
792
770
  #### Example
793
771
 
@@ -822,6 +800,28 @@ class UserBlueprint < Blueprinter::Base
822
800
  end
823
801
  ```
824
802
 
803
+ #### Transform across views
804
+
805
+ Transformers can be included across views:
806
+
807
+ ```ruby
808
+ class UserBlueprint < Blueprinter::Base
809
+ transform DefaultTransformer
810
+
811
+ view :normal do
812
+ transform ViewTransformer
813
+ end
814
+
815
+ view :extended do
816
+ include_view :normal
817
+ end
818
+ end
819
+ ```
820
+
821
+ Both the `normal` and `extended` views have `DefaultTransformer` and `ViewTransformer` applied.
822
+
823
+ Transformers are executed in a top-down order, so `DefaultTransformer` will be executed first, followed by `ViewTransformer`.
824
+
825
825
  #### Global Transforms
826
826
 
827
827
  You can also specify global default transformers. Create one or more transformer classes extending from `Blueprinter::Transformer` and set the `default_transformers` configuration
@@ -842,13 +842,11 @@ end
842
842
 
843
843
  **Note: Any transforms specified on a per-blueprint or per-view level will override the `default_transformers` in the configuration.**
844
844
 
845
- ---
846
845
  </details>
847
846
 
848
847
  <details>
849
848
  <summary>Configurable Extractors</summary>
850
849
 
851
- ---
852
850
 
853
851
  Blueprinter gets a given objects' values from the fields definitions using extractor classes. You can substitute your own extractor class globally or per-field.
854
852
 
@@ -896,13 +894,11 @@ Blueprinter.configure do |config|
896
894
  end
897
895
  ```
898
896
 
899
- ---
900
897
  </details>
901
898
 
902
899
  <details>
903
900
  <summary>Sorting Fields</summary>
904
901
 
905
- ---
906
902
 
907
903
  By default the response sorts the keys by name. If you want the fields to be sorted in the order of definition, use the below configuration option.
908
904
 
@@ -932,13 +928,11 @@ Output:
932
928
  }
933
929
  ```
934
930
 
935
- ---
936
931
  </details>
937
932
 
938
933
  <details>
939
934
  <summary>Deprecations</summary>
940
935
 
941
- ---
942
936
 
943
937
  When functionality in Blueprinter is invoked, that has been deprecated, the default behavior is to
944
938
  write a deprecation notice to stderror.
@@ -959,13 +953,11 @@ Blueprinter.configure do |config|
959
953
  end
960
954
  ```
961
955
 
962
- ---
963
956
  </details>
964
957
 
965
958
  <details>
966
959
  <summary>render_as_hash</summary>
967
960
 
968
- ---
969
961
 
970
962
  Same as `render`, returns a Ruby Hash.
971
963
 
@@ -984,13 +976,11 @@ Output:
984
976
  }
985
977
  ```
986
978
 
987
- ---
988
979
  </details>
989
980
 
990
981
  <details>
991
982
  <summary>render_as_json</summary>
992
983
 
993
- ---
994
984
 
995
985
  Same as `render`, returns a Ruby Hash JSONified. This will call JSONify all keys and values.
996
986
 
@@ -1009,7 +999,6 @@ Output:
1009
999
  }
1010
1000
  ```
1011
1001
 
1012
- ---
1013
1002
  </details>
1014
1003
 
1015
1004
  ## Installation