blueprinter 1.0.2 → 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 +4 -4
- data/CHANGELOG.md +13 -1
- data/README.md +108 -7
- data/Rakefile +1 -1
- data/lib/blueprinter/association.rb +35 -0
- data/lib/blueprinter/base.rb +21 -27
- data/lib/blueprinter/blueprint_validator.rb +34 -0
- data/lib/blueprinter/configuration.rb +3 -9
- data/lib/blueprinter/empty_types.rb +1 -1
- data/lib/blueprinter/errors/invalid_blueprint.rb +7 -0
- data/lib/blueprinter/errors.rb +7 -0
- data/lib/blueprinter/extractors/association_extractor.rb +4 -1
- data/lib/blueprinter/extractors/auto_extractor.rb +7 -0
- data/lib/blueprinter/extractors/block_extractor.rb +2 -0
- data/lib/blueprinter/extractors/hash_extractor.rb +2 -0
- data/lib/blueprinter/extractors/public_send_extractor.rb +2 -0
- data/lib/blueprinter/helpers/base_helpers.rb +22 -43
- data/lib/blueprinter/version.rb +1 -1
- data/lib/blueprinter/view_collection.rb +2 -0
- data/lib/blueprinter.rb +22 -3
- metadata +9 -5
- /data/{MIT-LICENSE → LICENSE.md} +0 -0
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,5 +1,17 @@
|
|
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
|
+
|
5
|
+
## 1.1.0 - 2024/08/02
|
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)
|
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).
|
8
|
+
* 💅 [ENHANCEMENT] Updates **Transform Classes** documentation to provide a more understandable example. See [#415](https://github.com/procore-oss/blueprinter/pull/415). Thanks to [@SaxtonDrey](https://github.com/SaxtonDrey).
|
9
|
+
* 💅 [ENHANCEMENT] Implements field-level configuration option for excluding an attribute from the result of a render if its value is `nil`. See [#425](https://github.com/procore-oss/blueprinter/pull/425). Thanks to [jamesst20](https://github.com/jamesst20).
|
10
|
+
* 🚜 [REFACTOR] Adds explicit dependency on `json` within `Blueprinter::Configuration`. See [#444](https://github.com/procore-oss/blueprinter/pull/444). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
|
11
|
+
* 🚜 [REFACTOR] Alters file loading to leverage `autoload` instead of `require` for (future) optional, top-level constants. See [#445](https://github.com/procore-oss/blueprinter/pull/445). Thanks to [@jhollinger](https://github.com/jhollinger).
|
12
|
+
|
1
13
|
## 1.0.2 - 2024/02/02
|
2
|
-
* 🐛 [BUGFIX] Fixes an issue with reflection where fields are incorrectly override by their definitions in the default view. See [#391](https://github.com/procore-oss/blueprinter/pull/391). Thanks to [@elliothursh](https://github.com/elliothursh).
|
14
|
+
* 🐛 [BUGFIX] [BREAKING] Fixes an issue with reflection where fields are incorrectly override by their definitions in the default view. Note: this may be a breaking change for users of the extensions API, but restores the intended functionality. See [#391](https://github.com/procore-oss/blueprinter/pull/391). Thanks to [@elliothursh](https://github.com/elliothursh).
|
3
15
|
|
4
16
|
## 1.0.1 - 2024/01/19
|
5
17
|
* 🐛 [BUGFIX] Fixes an issue where serialization performance would become degraded when using a Blueprint that leverages transformers. See [#381](https://github.com/procore-oss/blueprinter/pull/381). Thanks to [@Pritilender](https://github.com/Pritilender).
|
data/README.md
CHANGED
@@ -694,6 +694,36 @@ _NOTE:_ The field-level setting overrides the global config setting (for the fie
|
|
694
694
|
|
695
695
|
</details>
|
696
696
|
|
697
|
+
<details>
|
698
|
+
<summary>Exclude Fields with nil Values</summary>
|
699
|
+
|
700
|
+
|
701
|
+
By default, fields with `nil` values are included when rendering. You can override this behavior by setting `:exclude_if_nil: true` in the field definition.
|
702
|
+
|
703
|
+
Usage:
|
704
|
+
|
705
|
+
```ruby
|
706
|
+
class UserBlueprint < Blueprinter::Base
|
707
|
+
identifier :uuid
|
708
|
+
|
709
|
+
field :name
|
710
|
+
field :birthday, exclude_if_nil: true
|
711
|
+
end
|
712
|
+
|
713
|
+
user = User.new(name: 'John Doe')
|
714
|
+
puts UserBlueprint.render(user)
|
715
|
+
```
|
716
|
+
|
717
|
+
Output:
|
718
|
+
|
719
|
+
```json
|
720
|
+
{
|
721
|
+
"name": "John Doe"
|
722
|
+
}
|
723
|
+
```
|
724
|
+
|
725
|
+
</details>
|
726
|
+
|
697
727
|
<details>
|
698
728
|
<summary>Custom Formatting for Dates and Times</summary>
|
699
729
|
|
@@ -773,7 +803,7 @@ Create a Transform class extending from `Blueprinter::Transformer`
|
|
773
803
|
|
774
804
|
```ruby
|
775
805
|
class DynamicFieldTransformer < Blueprinter::Transformer
|
776
|
-
def transform(hash, object,
|
806
|
+
def transform(hash, object, _options)
|
777
807
|
hash.merge!(object.dynamic_fields)
|
778
808
|
end
|
779
809
|
end
|
@@ -781,12 +811,23 @@ end
|
|
781
811
|
|
782
812
|
```ruby
|
783
813
|
class User
|
784
|
-
def
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
814
|
+
def dynamic_fields
|
815
|
+
case role
|
816
|
+
when :admin
|
817
|
+
{
|
818
|
+
employer: employer,
|
819
|
+
time_in_role: determine_time_in role
|
820
|
+
}
|
821
|
+
when :maintainer
|
822
|
+
{
|
823
|
+
label: label,
|
824
|
+
settings: generate_settings_hash
|
825
|
+
}
|
826
|
+
when :read_only
|
827
|
+
{
|
828
|
+
last_login_at: last_login_at
|
829
|
+
}
|
830
|
+
end
|
790
831
|
end
|
791
832
|
end
|
792
833
|
```
|
@@ -930,6 +971,66 @@ Output:
|
|
930
971
|
|
931
972
|
</details>
|
932
973
|
|
974
|
+
<details>
|
975
|
+
<summary>Reflection</summary>
|
976
|
+
|
977
|
+
Blueprint classes may be reflected on to inspect their views, fields, and associations. Extensions often make use of this ability.
|
978
|
+
|
979
|
+
```ruby
|
980
|
+
class WidgetBlueprint < Blueprinter::Base
|
981
|
+
fields :name, :description
|
982
|
+
association :category, blueprint: CategoryBlueprint
|
983
|
+
|
984
|
+
view :extended do
|
985
|
+
field :price
|
986
|
+
association :parts, blueprint: WidgetPartBlueprint
|
987
|
+
end
|
988
|
+
end
|
989
|
+
|
990
|
+
# A Hash of views keyed by name
|
991
|
+
views = WidgetBlueprint.reflections
|
992
|
+
views.keys
|
993
|
+
=> [:default, :extended]
|
994
|
+
|
995
|
+
# Hashes of fields and associations, keyed by name
|
996
|
+
fields = views[:default].fields
|
997
|
+
assoc = views[:default].associations
|
998
|
+
|
999
|
+
# Get info about a field
|
1000
|
+
fields[:description].name
|
1001
|
+
fields[:description].display_name
|
1002
|
+
fields[:description].options
|
1003
|
+
|
1004
|
+
# Get info about an association
|
1005
|
+
assoc[:category].name
|
1006
|
+
assoc[:category].display_name
|
1007
|
+
assoc[:category].blueprint
|
1008
|
+
assoc[:category].view
|
1009
|
+
assoc[:category].options
|
1010
|
+
```
|
1011
|
+
</details>
|
1012
|
+
|
1013
|
+
<details>
|
1014
|
+
<summary>Extensions</summary>
|
1015
|
+
|
1016
|
+
Blueprinter offers an extension system to hook into and modify certain behavior.
|
1017
|
+
|
1018
|
+
```ruby
|
1019
|
+
Blueprinter.configure do |config|
|
1020
|
+
config.extensions << MyExtension.new
|
1021
|
+
config.extensions << OtherExtension.new
|
1022
|
+
end
|
1023
|
+
```
|
1024
|
+
|
1025
|
+
Extension hooks:
|
1026
|
+
|
1027
|
+
* [pre_render](https://github.com/procore-oss/blueprinter/blob/abca9ca8ed23edd65a0f4b5ae43e25b8e27a2afc/lib/blueprinter/extension.rb#L18): Intercept the object before rendering begins
|
1028
|
+
|
1029
|
+
Some known extensions are:
|
1030
|
+
|
1031
|
+
* [blueprinter-activerecord](https://github.com/procore-oss/blueprinter-activerecord)
|
1032
|
+
</details>
|
1033
|
+
|
933
1034
|
<details>
|
934
1035
|
<summary>Deprecations</summary>
|
935
1036
|
|
data/Rakefile
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'blueprinter/field'
|
4
|
+
require 'blueprinter/blueprint_validator'
|
5
|
+
require 'blueprinter/extractors/association_extractor'
|
6
|
+
|
7
|
+
module Blueprinter
|
8
|
+
# @api private
|
9
|
+
class Association < Field
|
10
|
+
# @param method [Symbol] The method to call on the source object to retrieve the associated data
|
11
|
+
# @param name [Symbol] The name of the association as it will appear when rendered
|
12
|
+
# @param blueprint [Blueprinter::Base] The blueprint to use for rendering the association
|
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
|
15
|
+
# @param extractor [Blueprinter::Extractor] The extractor to use when retrieving the associated data
|
16
|
+
# @param options [Hash]
|
17
|
+
#
|
18
|
+
# @return [Blueprinter::Association]
|
19
|
+
def initialize(method:, name:, blueprint:, view:, parent_blueprint:, extractor: AssociationExtractor.new, options: {})
|
20
|
+
BlueprintValidator.validate!(blueprint)
|
21
|
+
|
22
|
+
super(
|
23
|
+
method,
|
24
|
+
name,
|
25
|
+
extractor,
|
26
|
+
parent_blueprint,
|
27
|
+
options.merge(
|
28
|
+
blueprint: blueprint,
|
29
|
+
view: view,
|
30
|
+
association: true
|
31
|
+
)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/blueprinter/base.rb
CHANGED
@@ -1,23 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require_relative 'extractors/association_extractor'
|
9
|
-
require_relative 'extractors/auto_extractor'
|
10
|
-
require_relative 'extractors/block_extractor'
|
11
|
-
require_relative 'extractors/hash_extractor'
|
12
|
-
require_relative 'extractors/public_send_extractor'
|
13
|
-
require_relative 'formatters/date_time_formatter'
|
14
|
-
require_relative 'field'
|
15
|
-
require_relative 'helpers/type_helpers'
|
16
|
-
require_relative 'helpers/base_helpers'
|
17
|
-
require_relative 'view'
|
18
|
-
require_relative 'view_collection'
|
19
|
-
require_relative 'transformer'
|
20
|
-
require_relative 'reflection'
|
3
|
+
require 'blueprinter/association'
|
4
|
+
require 'blueprinter/extractors/association_extractor'
|
5
|
+
require 'blueprinter/field'
|
6
|
+
require 'blueprinter/helpers/base_helpers'
|
7
|
+
require 'blueprinter/reflection'
|
21
8
|
|
22
9
|
module Blueprinter
|
23
10
|
class Base
|
@@ -159,17 +146,24 @@ module Blueprinter
|
|
159
146
|
# end
|
160
147
|
# end
|
161
148
|
#
|
162
|
-
# @return [
|
149
|
+
# @return [Association] An object
|
150
|
+
# @raise [Blueprinter::Errors::InvalidBlueprint] if provided blueprint is not valid
|
163
151
|
def self.association(method, options = {}, &block)
|
164
|
-
|
152
|
+
raise ArgumentError, ':blueprint must be provided when defining an association' unless options[:blueprint]
|
165
153
|
|
166
|
-
|
167
|
-
method,
|
168
|
-
options.
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
154
|
+
current_view << Association.new(
|
155
|
+
method: method,
|
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)
|
173
167
|
)
|
174
168
|
end
|
175
169
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blueprinter
|
4
|
+
# @api private
|
5
|
+
class BlueprintValidator
|
6
|
+
class << self
|
7
|
+
# Determines whether the provided object is a valid Blueprint.
|
8
|
+
#
|
9
|
+
# @param blueprint [Object] The object to validate.
|
10
|
+
# @return [Boolean] true if object is a valid Blueprint
|
11
|
+
# @raise [Blueprinter::Errors::InvalidBlueprint] if the object is not a valid Blueprint.
|
12
|
+
def validate!(blueprint)
|
13
|
+
if valid_blueprint?(blueprint)
|
14
|
+
true
|
15
|
+
else
|
16
|
+
raise(
|
17
|
+
Errors::InvalidBlueprint,
|
18
|
+
"#{blueprint} is not a valid blueprint. Please ensure it subclasses Blueprinter::Base or is a Proc."
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def valid_blueprint?(blueprint)
|
26
|
+
return false unless blueprint
|
27
|
+
return true if blueprint.is_a?(Proc)
|
28
|
+
return false unless blueprint.is_a?(Class)
|
29
|
+
|
30
|
+
blueprint <= Blueprinter::Base
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'json'
|
4
|
+
require 'blueprinter/extensions'
|
5
|
+
require 'blueprinter/extractors/auto_extractor'
|
4
6
|
|
5
7
|
module Blueprinter
|
6
8
|
class Configuration
|
@@ -48,12 +50,4 @@ module Blueprinter
|
|
48
50
|
VALID_CALLABLES.include?(callable_name)
|
49
51
|
end
|
50
52
|
end
|
51
|
-
|
52
|
-
def self.configuration
|
53
|
-
@configuration ||= Configuration.new
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.configure
|
57
|
-
yield configuration if block_given?
|
58
|
-
end
|
59
53
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'blueprinter/extractor'
|
4
|
+
require 'blueprinter/empty_types'
|
5
|
+
|
3
6
|
module Blueprinter
|
4
7
|
# @api private
|
5
8
|
class AssociationExtractor < Extractor
|
@@ -10,7 +13,7 @@ module Blueprinter
|
|
10
13
|
end
|
11
14
|
|
12
15
|
def extract(association_name, object, local_options, options = {})
|
13
|
-
options_without_default = options.
|
16
|
+
options_without_default = options.except(:default, :default_if)
|
14
17
|
# Merge in assocation options hash
|
15
18
|
local_options = local_options.merge(options[:options]) if options[:options].is_a?(Hash)
|
16
19
|
value = @extractor.extract(association_name, object, local_options, options_without_default)
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'blueprinter/extractor'
|
4
|
+
require 'blueprinter/empty_types'
|
5
|
+
require 'blueprinter/extractors/block_extractor'
|
6
|
+
require 'blueprinter/extractors/hash_extractor'
|
7
|
+
require 'blueprinter/extractors/public_send_extractor'
|
8
|
+
require 'blueprinter/formatters/date_time_formatter'
|
9
|
+
|
3
10
|
module Blueprinter
|
4
11
|
# @api private
|
5
12
|
class AutoExtractor < Extractor
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'blueprinter/helpers/type_helpers'
|
4
|
+
require 'blueprinter/view_collection'
|
5
|
+
|
3
6
|
module Blueprinter
|
4
7
|
module BaseHelpers
|
5
8
|
def self.included(base)
|
@@ -12,11 +15,21 @@ module Blueprinter
|
|
12
15
|
private
|
13
16
|
|
14
17
|
def prepare_for_render(object, options)
|
15
|
-
view_name = options.
|
16
|
-
root = options
|
17
|
-
meta = options
|
18
|
+
view_name = options.fetch(:view, :default)
|
19
|
+
root = options[:root]
|
20
|
+
meta = options[:meta]
|
18
21
|
validate_root_and_meta!(root, meta)
|
19
|
-
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
|
+
)
|
20
33
|
end
|
21
34
|
|
22
35
|
def prepare_data(object, view_name, local_options)
|
@@ -48,7 +61,11 @@ module Blueprinter
|
|
48
61
|
result_hash = view_collection.fields_for(view_name).each_with_object({}) do |field, hash|
|
49
62
|
next if field.skip?(field.name, object, local_options)
|
50
63
|
|
51
|
-
|
64
|
+
value = field.extract(object, local_options)
|
65
|
+
|
66
|
+
next if value.nil? && field.options[:exclude_if_nil]
|
67
|
+
|
68
|
+
hash[field.name] = value
|
52
69
|
end
|
53
70
|
view_collection.transformers(view_name).each do |transformer|
|
54
71
|
transformer.transform(result_hash, object, local_options)
|
@@ -67,44 +84,6 @@ module Blueprinter
|
|
67
84
|
end
|
68
85
|
end
|
69
86
|
|
70
|
-
def dynamic_blueprint?(blueprint)
|
71
|
-
blueprint.is_a?(Proc)
|
72
|
-
end
|
73
|
-
|
74
|
-
def validate_blueprint!(blueprint, method)
|
75
|
-
validate_presence_of_blueprint!(blueprint)
|
76
|
-
return if dynamic_blueprint?(blueprint)
|
77
|
-
|
78
|
-
validate_blueprint_has_ancestors!(blueprint, method)
|
79
|
-
validate_blueprint_has_blueprinter_base_ancestor!(blueprint, method)
|
80
|
-
end
|
81
|
-
|
82
|
-
def validate_presence_of_blueprint!(blueprint)
|
83
|
-
raise BlueprinterError, 'Blueprint required' unless blueprint
|
84
|
-
end
|
85
|
-
|
86
|
-
def validate_blueprint_has_ancestors!(blueprint, association_name)
|
87
|
-
# If the class passed as a blueprint does not respond to ancestors
|
88
|
-
# it means it, at the very least, does not have Blueprinter::Base as
|
89
|
-
# one of its ancestor classes (e.g: Hash) and thus an error should
|
90
|
-
# be raised.
|
91
|
-
return if blueprint.respond_to?(:ancestors)
|
92
|
-
|
93
|
-
raise BlueprinterError, "Blueprint provided for #{association_name} " \
|
94
|
-
'association is not valid.'
|
95
|
-
end
|
96
|
-
|
97
|
-
def validate_blueprint_has_blueprinter_base_ancestor!(blueprint, association_name)
|
98
|
-
# Guard clause in case Blueprinter::Base is present in the ancestor list
|
99
|
-
# for the blueprint class provided.
|
100
|
-
return if blueprint.ancestors.include? Blueprinter::Base
|
101
|
-
|
102
|
-
# Raise error describing what's wrong.
|
103
|
-
raise BlueprinterError, "Class #{blueprint.name} does not inherit from " \
|
104
|
-
'Blueprinter::Base and is not a valid Blueprinter ' \
|
105
|
-
"for #{association_name} association."
|
106
|
-
end
|
107
|
-
|
108
87
|
def jsonify(blob)
|
109
88
|
Blueprinter.configuration.jsonify(blob)
|
110
89
|
end
|
data/lib/blueprinter/version.rb
CHANGED
data/lib/blueprinter.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'blueprinter/base'
|
4
|
-
require_relative 'blueprinter/extension'
|
5
|
-
|
6
3
|
module Blueprinter
|
4
|
+
autoload :Base, 'blueprinter/base'
|
5
|
+
autoload :BlueprinterError, 'blueprinter/blueprinter_error'
|
6
|
+
autoload :Configuration, 'blueprinter/configuration'
|
7
|
+
autoload :Errors, 'blueprinter/errors'
|
8
|
+
autoload :Extension, 'blueprinter/extension'
|
9
|
+
autoload :Transformer, 'blueprinter/transformer'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# @return [Configuration]
|
13
|
+
def configuration
|
14
|
+
@configuration ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield(configuration) if block_given?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Resets global configuration.
|
22
|
+
def reset_configuration!
|
23
|
+
@configuration = nil
|
24
|
+
end
|
25
|
+
end
|
7
26
|
end
|
metadata
CHANGED
@@ -1,35 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueprinter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 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
|
15
15
|
in Rails in place of other serializers (like JBuilder or ActiveModelSerializers).
|
16
16
|
It is designed to be simple, direct, and performant.
|
17
17
|
email:
|
18
|
-
-
|
18
|
+
- opensource@procore.com
|
19
19
|
executables: []
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
23
|
- CHANGELOG.md
|
24
|
-
-
|
24
|
+
- LICENSE.md
|
25
25
|
- README.md
|
26
26
|
- Rakefile
|
27
27
|
- lib/blueprinter.rb
|
28
|
+
- lib/blueprinter/association.rb
|
28
29
|
- lib/blueprinter/base.rb
|
30
|
+
- lib/blueprinter/blueprint_validator.rb
|
29
31
|
- lib/blueprinter/blueprinter_error.rb
|
30
32
|
- lib/blueprinter/configuration.rb
|
31
33
|
- lib/blueprinter/deprecation.rb
|
32
34
|
- lib/blueprinter/empty_types.rb
|
35
|
+
- lib/blueprinter/errors.rb
|
36
|
+
- lib/blueprinter/errors/invalid_blueprint.rb
|
33
37
|
- lib/blueprinter/extension.rb
|
34
38
|
- lib/blueprinter/extensions.rb
|
35
39
|
- lib/blueprinter/extractor.rb
|
@@ -63,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
67
|
requirements:
|
64
68
|
- - ">="
|
65
69
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
70
|
+
version: '3.0'
|
67
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
72
|
requirements:
|
69
73
|
- - ">="
|
/data/{MIT-LICENSE → LICENSE.md}
RENAMED
File without changes
|