rest_framework 0.7.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rest_framework/controller_mixins/base.rb +8 -2
- data/lib/rest_framework/controller_mixins/models.rb +5 -7
- data/lib/rest_framework/generators/controller_generator.rb +1 -1
- data/lib/rest_framework/serializers.rb +1 -1
- data/lib/rest_framework.rb +2 -2
- 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: 6e34db1e862327396b55e22abc5431e1b2679944c109e3313167bb387860c42c
|
4
|
+
data.tar.gz: 45597aaf31d61d53ffcfcebd632444cb1c69bf959f94647192d1749917fd5ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53ba45cf9b152c71c2db719e4f41890632e9f438f127ad6380d08e101a207eca5ef14b00c625de58854e618b410ac9709770687094cf6e2df5f7eb9ebd8814b4
|
7
|
+
data.tar.gz: 9552f475a0b11c8573825a4132e8683aad6943a2012f261b86538628c0c344d5755d8806629310e0162e77b9553cc4bf854c2d54170d8b5b4b80ab77c98ee87d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
@@ -8,7 +8,9 @@ require_relative "../utils"
|
|
8
8
|
module RESTFramework::BaseControllerMixin
|
9
9
|
RRF_BASE_CONTROLLER_CONFIG = {
|
10
10
|
filter_pk_from_request_body: true,
|
11
|
-
exclude_body_fields: [
|
11
|
+
exclude_body_fields: [
|
12
|
+
:created_at, :created_by, :created_by_id, :updated_at, :updated_by, :updated_by_id
|
13
|
+
].freeze,
|
12
14
|
accept_generic_params_as_body_params: false,
|
13
15
|
show_backtrace: false,
|
14
16
|
extra_actions: nil,
|
@@ -19,7 +21,7 @@ module RESTFramework::BaseControllerMixin
|
|
19
21
|
# Metadata and display options.
|
20
22
|
title: nil,
|
21
23
|
description: nil,
|
22
|
-
inflect_acronyms: ["ID", "REST", "API"],
|
24
|
+
inflect_acronyms: ["ID", "REST", "API"].freeze,
|
23
25
|
|
24
26
|
# Options related to serialization.
|
25
27
|
rescue_unknown_format_with: :json,
|
@@ -115,6 +117,7 @@ module RESTFramework::BaseControllerMixin
|
|
115
117
|
end
|
116
118
|
|
117
119
|
# Define any behavior to execute at the end of controller definition.
|
120
|
+
# :nocov:
|
118
121
|
def rrf_finalize
|
119
122
|
if RESTFramework.config.freeze_config
|
120
123
|
self::RRF_BASE_CONTROLLER_CONFIG.keys.each { |k|
|
@@ -123,6 +126,7 @@ module RESTFramework::BaseControllerMixin
|
|
123
126
|
}
|
124
127
|
end
|
125
128
|
end
|
129
|
+
# :nocov:
|
126
130
|
end
|
127
131
|
|
128
132
|
def self.included(base)
|
@@ -163,6 +167,7 @@ module RESTFramework::BaseControllerMixin
|
|
163
167
|
|
164
168
|
# Use `TracePoint` hook to automatically call `rrf_finalize`.
|
165
169
|
unless RESTFramework.config.disable_auto_finalize
|
170
|
+
# :nocov:
|
166
171
|
TracePoint.trace(:end) do |t|
|
167
172
|
next if base != t.self
|
168
173
|
|
@@ -172,6 +177,7 @@ module RESTFramework::BaseControllerMixin
|
|
172
177
|
# for performance.
|
173
178
|
t.disable
|
174
179
|
end
|
180
|
+
# :nocov:
|
175
181
|
end
|
176
182
|
end
|
177
183
|
|
@@ -44,7 +44,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
44
44
|
}
|
45
45
|
|
46
46
|
module ClassMethods
|
47
|
-
IGNORE_VALIDATORS_WITH_KEYS = [:if, :unless]
|
47
|
+
IGNORE_VALIDATORS_WITH_KEYS = [:if, :unless].freeze
|
48
48
|
|
49
49
|
# Get the model for this controller.
|
50
50
|
def get_model(from_get_recordset: false)
|
@@ -162,11 +162,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
162
162
|
|
163
163
|
# Get a hash of metadata to be rendered in the `OPTIONS` response. Cache the result.
|
164
164
|
def get_options_metadata(fields: nil)
|
165
|
-
return super().merge(
|
166
|
-
{
|
167
|
-
fields: self.get_fields_metadata(fields: fields),
|
168
|
-
},
|
169
|
-
)
|
165
|
+
return super().merge({fields: self.get_fields_metadata(fields: fields)})
|
170
166
|
end
|
171
167
|
|
172
168
|
def setup_delegation
|
@@ -204,6 +200,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
204
200
|
end
|
205
201
|
|
206
202
|
# Define any behavior to execute at the end of controller definition.
|
203
|
+
# :nocov:
|
207
204
|
def rrf_finalize
|
208
205
|
super
|
209
206
|
self.setup_delegation
|
@@ -216,6 +213,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
216
213
|
}
|
217
214
|
end
|
218
215
|
end
|
216
|
+
# :nocov:
|
219
217
|
end
|
220
218
|
|
221
219
|
def self.included(base)
|
@@ -276,7 +274,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
276
274
|
return _get_specific_action_config(
|
277
275
|
:allowed_action_parameters,
|
278
276
|
:allowed_parameters,
|
279
|
-
) || self.
|
277
|
+
) || self.get_fields
|
280
278
|
end
|
281
279
|
|
282
280
|
# Helper to get the configured serializer class, or `NativeSerializer` as a default.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "rails/generators"
|
2
2
|
|
3
3
|
# Most projects don't have the inflection "REST" as an acronym, so this is a helper class to prevent
|
4
|
-
# this generator from being namespaced
|
4
|
+
# this generator from being namespaced as `"r_e_s_t_framework"`.
|
5
5
|
# :nocov:
|
6
6
|
class RESTFrameworkCustomGeneratorControllerNamespace < String
|
7
7
|
def camelize
|
@@ -114,7 +114,7 @@ class RESTFramework::NativeSerializer < RESTFramework::BaseSerializer
|
|
114
114
|
return subcfg unless subcfg
|
115
115
|
|
116
116
|
if subcfg.is_a?(Array)
|
117
|
-
subcfg = subcfg.
|
117
|
+
subcfg = subcfg.map(&:to_sym)
|
118
118
|
|
119
119
|
if add
|
120
120
|
# Only add fields which are not already included.
|
data/lib/rest_framework.rb
CHANGED
@@ -7,7 +7,7 @@ module RESTFramework
|
|
7
7
|
BUILTIN_MEMBER_ACTIONS = {
|
8
8
|
show: :get,
|
9
9
|
edit: :get,
|
10
|
-
update: [:put, :patch],
|
10
|
+
update: [:put, :patch].freeze,
|
11
11
|
destroy: :delete,
|
12
12
|
}.freeze
|
13
13
|
RRF_BUILTIN_ACTIONS = {
|
@@ -24,7 +24,7 @@ module RESTFramework
|
|
24
24
|
# in:
|
25
25
|
# - Model delegation, for the helper methods to be defined dynamically.
|
26
26
|
# - Websockets, for `::Channel` class to be defined dynamically.
|
27
|
-
# - Controller configuration
|
27
|
+
# - Controller configuration finalization.
|
28
28
|
attr_accessor :disable_auto_finalize
|
29
29
|
|
30
30
|
# Freeze configuration attributes during finalization to prevent accidental mutation.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory N. Schmit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|