sinja 1.0.0.pre1 → 1.0.0.pre2
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 +13 -9
- data/lib/sinja/helpers/serializers.rb +16 -12
- data/lib/sinja/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c550d3cff0b520955dbd6add3f45fe426d0ba03
|
4
|
+
data.tar.gz: 2c0273185088e63db97d8a1de1e6c8612f9999c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beaec25e26829f91f373e886449a64d10629f4905c1fb809576522aa866cd7843bd61c263fb219e566fe17fe2f31c59d0565c5c4230d10e9acd23bd4b09dc781
|
7
|
+
data.tar.gz: d7d470ba61bc03da60129b9e8566b5bd98fdcf7e6223f4e59e72c112bca2fdbfc8d026e209aeb4a651493281a6e38e0f247733ddd906dbefd4c2bce66ee44177
|
data/README.md
CHANGED
@@ -277,6 +277,17 @@ end
|
|
277
277
|
: Returns the `data` key of the deserialized request payload (with symbolized
|
278
278
|
names).
|
279
279
|
|
280
|
+
**dedasherize**
|
281
|
+
: Takes a string or symbol and returns the string or symbol with any and all
|
282
|
+
dashes transliterated to underscores.
|
283
|
+
|
284
|
+
**dedasherize_names**
|
285
|
+
: Takes a hash and returns the hash with its keys dedasherized (deeply).
|
286
|
+
|
287
|
+
**role?**
|
288
|
+
: Takes a list of role(s) and returns true if it has members in common with the
|
289
|
+
current user's role(s).
|
290
|
+
|
280
291
|
**serialize_model**
|
281
292
|
: Takes a model (and optional hash of JSONAPI::Serializers options) and returns
|
282
293
|
a serialized model.
|
@@ -295,13 +306,6 @@ end
|
|
295
306
|
and returns a serialized collection if non-empty, or the root metadata if
|
296
307
|
present, or a HTTP status 204.
|
297
308
|
|
298
|
-
**dedasherize**
|
299
|
-
: Takes a string or symbol and returns the string or symbol with any and all
|
300
|
-
dashes transliterated to underscores.
|
301
|
-
|
302
|
-
**dedasherize_names**
|
303
|
-
: Takes a hash and returns the hash with its keys dedasherized (deeply).
|
304
|
-
|
305
309
|
**sideloaded?**
|
306
310
|
: Returns true if the request was invoked from another action helper.
|
307
311
|
|
@@ -626,8 +630,8 @@ end
|
|
626
630
|
```
|
627
631
|
|
628
632
|
You may invoke an action helper keyword without a block to modify the options
|
629
|
-
(i.e. roles) of a previously-registered action helper while
|
630
|
-
existing behavior:
|
633
|
+
(i.e. roles and sideloading) of a previously-registered action helper while
|
634
|
+
preseving the existing behavior:
|
631
635
|
|
632
636
|
```ruby
|
633
637
|
resource :bars do
|
@@ -68,20 +68,24 @@ module Sinja
|
|
68
68
|
|
69
69
|
# Walk the tree and try to exclude based on fetch and pluck permissions
|
70
70
|
included.keep_if do |termstr|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
roles
|
79
|
-
|
71
|
+
catch :keep? do
|
72
|
+
*terms, last_term = termstr.split('.')
|
73
|
+
|
74
|
+
# Start cursor at root of current resource
|
75
|
+
roles = settings._resource_roles
|
76
|
+
terms.each do |term|
|
77
|
+
# Move cursor through each term, avoiding the default proc,
|
78
|
+
# halting if no roles found, i.e. client asked to include
|
79
|
+
# something that Sinja doesn't know about
|
80
|
+
throw :keep?, true \
|
81
|
+
unless roles = settings._sinja.resource_roles.fetch(term.pluralize.to_sym, nil)
|
82
|
+
end
|
80
83
|
|
81
|
-
|
82
|
-
|
84
|
+
roles =
|
85
|
+
roles.dig(:has_many, last_term.pluralize.to_sym, :fetch) ||
|
86
|
+
roles.dig(:has_one, last_term.singularize.to_sym, :pluck)
|
83
87
|
|
84
|
-
|
88
|
+
throw :keep?, roles && (roles.empty? || roles === memoized_role)
|
85
89
|
end
|
86
90
|
end
|
87
91
|
end
|
data/lib/sinja/version.rb
CHANGED