blueprinter-rb 1.1.2 → 1.2.0
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/README.md +3 -3
- data/lib/blueprinter/empty_types.rb +0 -5
- data/lib/blueprinter/field.rb +0 -11
- data/lib/blueprinter/version.rb +1 -1
- metadata +3 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0c11b02470f7704449b1aba7833ced1bba7a33d16faf0becacf9d4da49d8036
|
|
4
|
+
data.tar.gz: c58f725526c7e4c3a58b396c90a95758a166093b4dccddcdcef349d5ebceebc0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0beefb4966398bc05767181f03e3388066a34193ad3ea9af8703cd58af3bac1edad9dba946132a7d659bbe87d387df8d93eb81b0635ed882ab5b172e3a9160e4
|
|
7
|
+
data.tar.gz: 95f1e8e862f7801b335182a448ca6bee2f7af4813e3c6b910084939d69c1d8f1bcdb15d85a043c9ae12e5f73fcd2ea40f04336b3d8942ba591fb89c18afa40d9
|
data/README.md
CHANGED
|
@@ -453,9 +453,9 @@ class UserBlueprint < Blueprinter::Base
|
|
|
453
453
|
|
|
454
454
|
view :normal do
|
|
455
455
|
# If first_name is an empty string, it will become "N/A"
|
|
456
|
-
field :first_name, default_if: Blueprinter::
|
|
456
|
+
field :first_name, default_if: Blueprinter::EMPTY_STRING, default: "N/A"
|
|
457
457
|
# If the projects association collection is empty, it will become nil
|
|
458
|
-
association :projects, blueprint: ProjectBlueprint, default_if: Blueprinter::
|
|
458
|
+
association :projects, blueprint: ProjectBlueprint, default_if: Blueprinter::EMPTY_COLLECTION
|
|
459
459
|
end
|
|
460
460
|
end
|
|
461
461
|
```
|
|
@@ -954,7 +954,7 @@ $ bundle
|
|
|
954
954
|
|
|
955
955
|
Or install it yourself as:
|
|
956
956
|
```bash
|
|
957
|
-
$ gem install blueprinter
|
|
957
|
+
$ gem install blueprinter-rb
|
|
958
958
|
```
|
|
959
959
|
|
|
960
960
|
You should also have `require 'json'` already in your project if you are not using Rails or if you are not using Oj.
|
|
@@ -22,11 +22,6 @@ module Blueprinter
|
|
|
22
22
|
value.is_a?(Hash) && value.empty?
|
|
23
23
|
when Blueprinter::EMPTY_STRING
|
|
24
24
|
value.to_s == ''
|
|
25
|
-
else
|
|
26
|
-
Blueprinter::Deprecation.report(
|
|
27
|
-
"Invalid empty type '#{empty_type}' received. Blueprinter will raise an error in the next major version." \
|
|
28
|
-
'Must be one of [nil, Blueprinter::EMPTY_COLLECTION, Blueprinter::EMPTY_HASH, Blueprinter::EMPTY_STRING]'
|
|
29
|
-
)
|
|
30
25
|
end
|
|
31
26
|
end
|
|
32
27
|
end
|
data/lib/blueprinter/field.rb
CHANGED
|
@@ -38,17 +38,6 @@ module Blueprinter
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def callable_from(condition)
|
|
41
|
-
callable = old_callable_from(condition)
|
|
42
|
-
|
|
43
|
-
if callable && callable.arity == 2
|
|
44
|
-
Blueprinter::Deprecation.report("`:#{condition}` conditions now expects 3 arguments instead of 2.")
|
|
45
|
-
->(_field_name, obj, options) { callable.call(obj, options) }
|
|
46
|
-
else
|
|
47
|
-
callable
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def old_callable_from(condition)
|
|
52
41
|
config = Blueprinter.configuration
|
|
53
42
|
|
|
54
43
|
# Use field-level callable, or when not defined, try global callable
|
data/lib/blueprinter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,43 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blueprinter-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ritikesh G
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: oj
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '3.13'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '3.13'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: yajl-ruby
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.4'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.4'
|
|
11
|
+
date: 2023-07-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
41
13
|
description: Blueprinter is a JSON Object Presenter for Ruby that takes business objects
|
|
42
14
|
and breaksthem down into simple hashes and serializes them to JSON. It can be used
|
|
43
15
|
in Rails in place of otherserializers (like JBuilder or ActiveModelSerializers).
|