Class: ScimPatch
- Inherits:
-
Object
- Object
- ScimPatch
- Defined in:
- app/libraries/scim_patch.rb
Overview
Parse PATCH request
Instance Attribute Summary collapse
-
#operations ⇒ Object
Returns the value of attribute operations.
Instance Method Summary collapse
-
#initialize(params, mutable_attributes_schema) ⇒ ScimPatch
constructor
A new instance of ScimPatch.
- #save(model) ⇒ Object
Constructor Details
#initialize(params, mutable_attributes_schema) ⇒ ScimPatch
Returns a new instance of ScimPatch.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/libraries/scim_patch.rb', line 7 def initialize(params, mutable_attributes_schema) # FIXME: raise proper error. unless params['schemas'] == ['urn:ietf:params:scim:api:messages:2.0:PatchOp'] raise StandardError end if params['Operations'].nil? raise ScimRails::ExceptionHandler::UnsupportedPatchRequest end @operations = params['Operations'].map do |operation| ScimPatchOperation.new(operation['op'], operation['path'], operation['value'], mutable_attributes_schema) end end |
Instance Attribute Details
#operations ⇒ Object
Returns the value of attribute operations.
5 6 7 |
# File 'app/libraries/scim_patch.rb', line 5 def operations @operations end |
Instance Method Details
#save(model) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/libraries/scim_patch.rb', line 22 def save(model) model.transaction do @operations.each do |operation| operation.save(model) end model.save! if model.changed? end rescue ActiveRecord::RecordNotFound raise rescue StandardError raise ScimRails::ExceptionHandler::UnsupportedPatchRequest end |