scimitar 2.7.0 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/app/models/scimitar/resources/base.rb +12 -9
- data/app/models/scimitar/resources/mixin.rb +403 -33
- data/lib/scimitar/support/hash_with_indifferent_case_insensitive_access.rb +140 -10
- data/lib/scimitar/version.rb +2 -2
- data/spec/models/scimitar/resources/base_spec.rb +9 -1
- data/spec/models/scimitar/resources/mixin_spec.rb +683 -112
- data/spec/requests/active_record_backed_resources_controller_spec.rb +81 -5
- data/spec/support/hash_with_indifferent_case_insensitive_access_spec.rb +108 -0
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6898633f866963ccaacd5f16120a957f698e2e1aacd51b985c483616fe5c49d5
|
4
|
+
data.tar.gz: d24f2017fab7ae3432c21d5eacb281fa8cd1ac3b43a25756ccbf105a426bf85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cefe2b8fb441822a751ba93d54b43dc6e75281cc707095f3880c9927d413d310dbcb0676405499f46e641cb767a6d50d3d03b9a0d1b6d1218fbd59e3c036caba
|
7
|
+
data.tar.gz: 34bc849312df18601c49df4f7e9019ed258b74bb84a002309a5d33b8119c4776edfb1e7cbacdcebbc92533b9cf63586c33631ac505ca1bb17bc859a9d1a65078
|
data/README.md
CHANGED
@@ -244,8 +244,6 @@ If you use ActiveRecord, your controllers can potentially be extremely simple by
|
|
244
244
|
module Scim
|
245
245
|
class UsersController < Scimitar::ActiveRecordBackedResourcesController
|
246
246
|
|
247
|
-
skip_before_action :verify_authenticity_token
|
248
|
-
|
249
247
|
protected
|
250
248
|
|
251
249
|
def storage_class
|
@@ -264,7 +262,7 @@ All data-layer actions are taken via `#find` or `#save!`, with exceptions such a
|
|
264
262
|
|
265
263
|
##### Overriding controller methods
|
266
264
|
|
267
|
-
You can overwrite write-based controller methods `#create`, `#update`, `#replace` and
|
265
|
+
You can overwrite write-based controller methods `#create`, `#update`, `#replace` and `#destroy` in your controller subclass, should you wish, wherein a call to `super` is passed a block. The block is invoked with the instance of a new unsaved record for `#create`, the updated record that needs to have its changes saved for `#update` and `#replace` and the record that should be destroyed for `#destroy`. This allows you to do things like applying business logic, default values, extra request-derived data and so-forth before then calling `record.save!`, or using some different method other than `record.destroy!` to discard a record (e.g. you might be using soft-delete, or want to skip all callbacks for some reason via `record.delete`).
|
268
266
|
|
269
267
|
* The `#destroy` method just calls `record.destroy!` unless a block is given, with nothing much else to say about it.
|
270
268
|
|
@@ -129,7 +129,7 @@ module Scimitar
|
|
129
129
|
|
130
130
|
if scim_attribute && scim_attribute.complexType
|
131
131
|
if scim_attribute.multiValued
|
132
|
-
self.send("#{attr_name}=", attr_value
|
132
|
+
self.send("#{attr_name}=", attr_value&.map {|attr_for_each_item| complex_type_from_hash(scim_attribute, attr_for_each_item)})
|
133
133
|
else
|
134
134
|
self.send("#{attr_name}=", complex_type_from_hash(scim_attribute, attr_value))
|
135
135
|
end
|
@@ -137,18 +137,21 @@ module Scimitar
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
# Renders *in full* as JSON; typically used for write-based operations...
|
141
|
+
#
|
142
|
+
# record = self.storage_class().new
|
143
|
+
# record.from_scim!(scim_hash: scim_resource.as_json())
|
144
|
+
# self.save!(record)
|
145
|
+
#
|
146
|
+
# ...so all fields, even those marked "returned: false", are included.
|
147
|
+
# Use Scimitar::Resources::Mixin::to_scim to obtain a SCIM object with
|
148
|
+
# non-returnable fields omitted, rendering *that* as JSON via #to_json.
|
149
|
+
#
|
140
150
|
def as_json(options = {})
|
141
151
|
self.meta = Meta.new unless self.meta && self.meta.is_a?(Meta)
|
142
152
|
self.meta.resourceType = self.class.resource_type_id
|
143
153
|
|
144
|
-
|
145
|
-
.schemas
|
146
|
-
.flat_map(&:scim_attributes)
|
147
|
-
.filter_map { |attribute| attribute.name if attribute.returned == 'never' }
|
148
|
-
|
149
|
-
non_returnable_attributes << 'errors'
|
150
|
-
|
151
|
-
original_hash = super(options).except(*non_returnable_attributes)
|
154
|
+
original_hash = super(options).except('errors')
|
152
155
|
original_hash.merge!('schemas' => self.class.schemas.map(&:id))
|
153
156
|
|
154
157
|
self.class.extended_schemas.each do |extension_schema|
|