Class: TwoPercent::Scim::PatchProcessor
- Inherits:
-
Object
- Object
- TwoPercent::Scim::PatchProcessor
- Defined in:
- lib/two_percent/scim/patch_processor.rb
Overview
SCIM RFC 7644 PATCH operation processor Handles add, replace, remove operations on SCIM resources
Instance Attribute Summary collapse
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #apply_to_hash(scim_hash) ⇒ Object
-
#initialize(patch_request) ⇒ PatchProcessor
constructor
A new instance of PatchProcessor.
Constructor Details
#initialize(patch_request) ⇒ PatchProcessor
Returns a new instance of PatchProcessor.
10 11 12 |
# File 'lib/two_percent/scim/patch_processor.rb', line 10 def initialize(patch_request) @operations = parse_operations(patch_request) end |
Instance Attribute Details
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
8 9 10 |
# File 'lib/two_percent/scim/patch_processor.rb', line 8 def operations @operations end |
Instance Method Details
#apply_to_hash(scim_hash) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/two_percent/scim/patch_processor.rb', line 14 def apply_to_hash(scim_hash) result = scim_hash.deep_dup operations.each do |operation| case operation[:op].downcase when "add" apply_add(result, operation[:path], operation[:value]) when "replace" apply_replace(result, operation[:path], operation[:value]) when "remove" apply_remove(result, operation[:path]) else raise ArgumentError, "Unknown PATCH operation: #{operation[:op]}" end end result end |