pi-resources-rails 0.1.1 → 0.3.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/lib/pi_resources/renderers.rb +10 -2
- data/lib/pi_resources/resources_controller.rb +14 -1
- data/lib/pi_resources/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: 0c4b766add63a0263d824a383b59f793bc42aaea92223c0987de1ede22d71bcd
|
4
|
+
data.tar.gz: ef5862948f21b5b5ba3d58ea20e2f62642c701fe3c161a2cbc6b4afba6f1666e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd52cc2e0f8ff3fb94149aab6b0f05f24818b483cb542f99e6558aa617043d16622d192772d716149aa4caf52219b9467b6944e0aa8091fcacccaca66b0a41cc
|
7
|
+
data.tar.gz: a425ccaa6ce24b0e0c0602024059e3bf1492fca97d067d2d0670338e84342bd50ca88778d33e25ffa283634decfe9e63b62f8ef80a255a2437f2398c1bd99d94
|
@@ -3,8 +3,6 @@
|
|
3
3
|
ActionController::Renderers.add :resource do |resource, options|
|
4
4
|
options = options.slice(:serializer, :meta, :message, :context, :message, :location)
|
5
5
|
|
6
|
-
puts options.inspect
|
7
|
-
|
8
6
|
result = options[:serializer].new(resource, meta: options[:meta], message: options[:message]).as_json
|
9
7
|
|
10
8
|
self.content_type = Mime[:json]
|
@@ -19,3 +17,13 @@ ActionController::Renderers.add :resource_errors do |errors, _options|
|
|
19
17
|
|
20
18
|
result
|
21
19
|
end
|
20
|
+
|
21
|
+
ActionController::Renderers.add :exception do |exception, options|
|
22
|
+
options = options.slice(:status, :error)
|
23
|
+
|
24
|
+
result = PiResources::Serializer::ExceptionSerializer.new(exception: exception, root: false, **options).as_json
|
25
|
+
|
26
|
+
self.content_type = Mime[:json]
|
27
|
+
|
28
|
+
result
|
29
|
+
end
|
@@ -11,7 +11,8 @@ module PiResources
|
|
11
11
|
|
12
12
|
render resource: @resource_collection,
|
13
13
|
serializer: index_resource_serializer,
|
14
|
-
context: context
|
14
|
+
context: context,
|
15
|
+
meta: meta
|
15
16
|
end
|
16
17
|
|
17
18
|
def show
|
@@ -20,6 +21,7 @@ module PiResources
|
|
20
21
|
render resource: @resource,
|
21
22
|
serializer: show_resource_serializer,
|
22
23
|
context: context,
|
24
|
+
meta: meta,
|
23
25
|
location: resource_location
|
24
26
|
end
|
25
27
|
|
@@ -30,6 +32,7 @@ module PiResources
|
|
30
32
|
render resource: @resource,
|
31
33
|
serializer: create_resource_serializer,
|
32
34
|
context: context,
|
35
|
+
meta: meta,
|
33
36
|
message: create_message,
|
34
37
|
location: resource_location
|
35
38
|
else
|
@@ -44,6 +47,7 @@ module PiResources
|
|
44
47
|
render resource: @resource,
|
45
48
|
serializer: update_resource_serializer,
|
46
49
|
context: context,
|
50
|
+
meta: meta,
|
47
51
|
message: update_message,
|
48
52
|
location: resource_location
|
49
53
|
else
|
@@ -58,6 +62,7 @@ module PiResources
|
|
58
62
|
render resource: @resource,
|
59
63
|
serializer: destroy_resource_serializer,
|
60
64
|
context: context,
|
65
|
+
meta: meta,
|
61
66
|
message: destroy_message,
|
62
67
|
location: resource_location
|
63
68
|
else
|
@@ -71,6 +76,14 @@ module PiResources
|
|
71
76
|
@context ||= {}
|
72
77
|
end
|
73
78
|
|
79
|
+
def add_meta(key, value)
|
80
|
+
meta[key] = value
|
81
|
+
end
|
82
|
+
|
83
|
+
def meta
|
84
|
+
@meta ||= {}
|
85
|
+
end
|
86
|
+
|
74
87
|
def resource_service
|
75
88
|
resource_service_class.new
|
76
89
|
end
|
data/lib/pi_resources/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pi-resources-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umberto Peserico
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-08-
|
12
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: money
|