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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63de55fe4d1ab41c577b2af07fafa7285fbee265d0dcc9d7b28f452739efd1fe
4
- data.tar.gz: 130cbc6ceddbc5d867eff3f567f087e7345c6adb28231388a89a38cda72db9eb
3
+ metadata.gz: 6898633f866963ccaacd5f16120a957f698e2e1aacd51b985c483616fe5c49d5
4
+ data.tar.gz: d24f2017fab7ae3432c21d5eacb281fa8cd1ac3b43a25756ccbf105a426bf85f
5
5
  SHA512:
6
- metadata.gz: b7d1272b4540c082ff3ab0b2d7fdc79d8b1fd502f9f37a219d58fd185512daf2f3b77ddfa2a61ccf335fe994a8b141b31ab48012bf6674df8986b69bca1bce99
7
- data.tar.gz: 710683faceb05f8402016a76b4991358928a6ab62cde698d5a88c02f5c842d9a4f109ab443ff1170dce83f5d187075622c398746cba3f8647ee8732eafab0eaf
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 `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`).
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.map {|attr_for_each_item| complex_type_from_hash(scim_attribute, attr_for_each_item)})
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
- non_returnable_attributes = self.class
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|