restme 1.2.1 → 1.2.2
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 +1 -1
- data/lib/restme/scope/field/rules.rb +4 -0
- data/lib/restme/scope/rules.rb +16 -14
- data/lib/restme/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1719cb8e1a96b0e12a5015c3eca4c6acfdb3542d6df849f84abdd2aea05a812b
|
4
|
+
data.tar.gz: d49bac58ef0983dbbfd4f56710c2b31f8cfe01e1e0d62f886c296b0ea88d98ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e703777e66829853afd8fcb560b2d02e3760249ef604d6af9deb9ee6419dcbd5f34f09589d787a9010fd52ac6b78fc744628e77306635bc5b24f9d0a5ec9ec56
|
7
|
+
data.tar.gz: 474185500814429aed08447b12b89cf9a5109b133354b8ba347d01cb1de7cc81d4a23047e4159761ea6ddb120719e6b4ae3c792222c752c9270f589dd39c7313
|
data/README.md
CHANGED
@@ -19,6 +19,10 @@ module Restme
|
|
19
19
|
scoped = select_nested_scope(scoped) if valid_nested_fields_select
|
20
20
|
|
21
21
|
insert_attachments(scoped)
|
22
|
+
rescue ActiveModel::MissingAttributeError => e
|
23
|
+
restme_scope_errors({ body: model_fields_select, message: e.message })
|
24
|
+
|
25
|
+
restme_scope_status(:bad_request)
|
22
26
|
end
|
23
27
|
|
24
28
|
def select_nested_scope(scoped)
|
data/lib/restme/scope/rules.rb
CHANGED
@@ -22,7 +22,7 @@ module Restme
|
|
22
22
|
include ::Restme::Shared::CurrentModel
|
23
23
|
include ::Restme::Shared::RestmeCurrentUserRole
|
24
24
|
|
25
|
-
attr_reader :
|
25
|
+
attr_reader :filterable_scope_response
|
26
26
|
attr_writer :restme_scope_errors, :restme_scope_status
|
27
27
|
|
28
28
|
SCOPE_ERROR_METHODS = %i[
|
@@ -33,12 +33,16 @@ module Restme
|
|
33
33
|
].freeze
|
34
34
|
|
35
35
|
def pagination_response
|
36
|
-
@pagination_response ||=
|
36
|
+
@pagination_response ||= begin
|
37
|
+
prepare_model_scope
|
38
|
+
|
39
|
+
restme_scope_errors.presence || restme_pagination_response
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
def model_scope_object
|
40
44
|
@model_scope_object ||= begin
|
41
|
-
|
45
|
+
prepare_model_scope
|
42
46
|
|
43
47
|
restme_scope_errors.presence || model_scope.first
|
44
48
|
end
|
@@ -47,14 +51,16 @@ module Restme
|
|
47
51
|
private
|
48
52
|
|
49
53
|
def restme_pagination_response
|
50
|
-
|
51
|
-
|
52
|
-
restme_scope_errors.presence || {
|
54
|
+
{
|
53
55
|
objects: model_scope,
|
54
56
|
pagination: pagination
|
55
57
|
}
|
56
58
|
end
|
57
59
|
|
60
|
+
def prepare_model_scope
|
61
|
+
model_scope if any_scope_errors.blank?
|
62
|
+
end
|
63
|
+
|
58
64
|
def any_scope_errors
|
59
65
|
SCOPE_ERROR_METHODS.each { |m| send(m) }
|
60
66
|
|
@@ -84,16 +90,12 @@ module Restme
|
|
84
90
|
end
|
85
91
|
|
86
92
|
def custom_scope
|
87
|
-
|
93
|
+
@filterable_scope_response = filterable_scope(user_scope)
|
88
94
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
fieldable_scope(paginable_scope_response)
|
93
|
-
end
|
95
|
+
scope = sortable_scope(filterable_scope_response)
|
96
|
+
scope = paginable_scope(scope)
|
94
97
|
|
95
|
-
|
96
|
-
@filterable_scope_response ||= filterable_scope(user_scope)
|
98
|
+
fieldable_scope(scope)
|
97
99
|
end
|
98
100
|
|
99
101
|
def user_scope
|
data/lib/restme/version.rb
CHANGED