render_json_rails 0.2.3 → 0.2.4
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 +15 -2
- data/lib/render_json_rails/concern.rb +2 -1
- data/lib/render_json_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45cb03b09ad6e494373405d1524552c31741dee3420fb302c418f2670b54afd2
|
4
|
+
data.tar.gz: ac0edad6f9e709e0fd1d77c4876e82a83b3ab0fab741fd68122b4062e1ca88d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73358a60ed892f9f774e2ebfd20a3ecf01ae79d972ecb1559b81e4a476589c7b6aaeee7e4e01f0220d9b6627d944147c6ab254bf8edb9c416a1d5b0003b38f78
|
7
|
+
data.tar.gz: aad4a298e8f210da9f11f6e7c2100c31666e672eebf26b56318ea2871ba6d0166e48ee42e4ca8d58076454f0a94d3b1b1b772dbe5879154f8a7d604eb5a007a8
|
data/README.md
CHANGED
@@ -67,19 +67,32 @@ http://example.test/teams/1.json?fields[team]=name,description
|
|
67
67
|
i możemy łączyć to z include
|
68
68
|
|
69
69
|
```html
|
70
|
-
http://example.
|
70
|
+
http://example.test/teams/1.json?fields[team]=name,description&fields[user]=email,name&include=users
|
71
71
|
```
|
72
72
|
|
73
73
|
include mogą być zagnieżdżane (po kropce)
|
74
74
|
|
75
75
|
```html
|
76
|
-
http://example.
|
76
|
+
http://example.test/teams/1.json?fields[team]=name,description&fields[user]=email,name&fields[role]=name&include=users,users.roles
|
77
77
|
```
|
78
78
|
|
79
|
+
### Additional Fields
|
80
|
+
|
81
|
+
aby wyświetlić domyślne pola oraz np. dodatkowe metody używamy `additional_fields` (dzięki temu nie trzeba wypisywać wszystkich domyślnych pól, gdy chcemy wyświetlić dodatkową jakąś metodę z `allowed_methods`)
|
82
|
+
|
83
|
+
```html
|
84
|
+
http://example.test/teams/1.json?additional_fields[user]=calculate_age # wyświetli wszystkie pole usera oraz dodatkowo `calculate_age`
|
85
|
+
```
|
86
|
+
|
87
|
+
|
79
88
|
## Wiecej przykładów użycia
|
80
89
|
|
90
|
+
`http://example.test/data/9.json?formatted=yes&include=positions,positions.correction_before,positions.correction_after,department,invoice,invoices,invoice.positions&fields[invoice]=id,invoice_id,positions&fields[department]=name,id&fields[invoice_position]=id,name,tax`
|
91
|
+
|
81
92
|
Więcej przykładów jest w testach: [test/render_json_rails_test.rb](test/render_json_rails_test.rb)
|
82
93
|
|
94
|
+
|
95
|
+
|
83
96
|
## Wszystkie opcje ```render_json_config```
|
84
97
|
|
85
98
|
```ruby
|
@@ -89,7 +89,8 @@ module RenderJsonRails
|
|
89
89
|
current_json_config[:includes]&.each do |model_name, klass|
|
90
90
|
if includes.include?(model_name.to_s)
|
91
91
|
includes2 = RenderJsonRails::Concern.includes_for_model(includes: includes, model: model_name.to_s)
|
92
|
-
include_options << { model_name => klass.render_json_options(includes: includes2, fields: fields
|
92
|
+
include_options << { model_name => klass.render_json_options(includes: includes2, fields: fields,
|
93
|
+
additional_fields: additional_fields) }
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_json_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
80
|
+
rubygems_version: 3.4.6
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Simle JSON API render like JonApi
|