Sha256: 06504bbcb95d4e60f71fa464b2c019e11037bb6d09cd2af82b22ae53a528242c
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true # Parse PATCH request class ScimPatch attr_accessor :operations def initialize(params, resource_type) if params['schemas'] != ['urn:ietf:params:scim:api:messages:2.0:PatchOp'] || params['Operations'].nil? raise ScimRails::ExceptionHandler::UnsupportedPatchRequest end # complex-value(Hash) operation is converted to multiple single-value operations converted_operations = ScimPatchOperationConverter.convert(params['Operations']) @operations = converted_operations.map do |o| create_operation(resource_type, o['op'], o['path'], o['value']) end end def create_operation(resource_type, op, path, value) if resource_type == :user ScimPatchOperationUser.new(op, path, value) else ScimPatchOperationGroup.new(op, path, value) end end 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scimaenaga-0.9.0 | app/libraries/scim_patch.rb |
scimaenaga-0.8.0 | app/libraries/scim_patch.rb |