Class: DeviseScim::Scim::PatchOperation
- Inherits:
-
Object
- Object
- DeviseScim::Scim::PatchOperation
- Defined in:
- lib/devise_scim/scim/patch_operation.rb
Constant Summary collapse
- VALID_OPS =
%w[add remove replace].freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#raw_path ⇒ Object
readonly
Returns the value of attribute raw_path.
-
#sub_attribute ⇒ Object
readonly
Returns the value of attribute sub_attribute.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(operation:, path:, value: nil) ⇒ PatchOperation
constructor
A new instance of PatchOperation.
Constructor Details
#initialize(operation:, path:, value: nil) ⇒ PatchOperation
Returns a new instance of PatchOperation.
24 25 26 27 28 29 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 24 def initialize(operation:, path:, value: nil) @op = operation @raw_path = path @value = value parse_path(path) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
10 11 12 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 10 def attribute @attribute end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
10 11 12 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 10 def filter @filter end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
10 11 12 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 10 def op @op end |
#raw_path ⇒ Object (readonly)
Returns the value of attribute raw_path.
10 11 12 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 10 def raw_path @raw_path end |
#sub_attribute ⇒ Object (readonly)
Returns the value of attribute sub_attribute.
10 11 12 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 10 def sub_attribute @sub_attribute end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 10 def value @value end |
Class Method Details
.parse(hash) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 12 def self.parse(hash) operation = hash["op"]&.downcase raise ArgumentError, "Invalid op '#{hash["op"]}'; must be one of: #{VALID_OPS.join(", ")}" unless VALID_OPS.include?(operation) new(operation: operation, path: hash["path"], value: hash["value"]) end |
.parse_request(body) ⇒ Object
19 20 21 22 |
# File 'lib/devise_scim/scim/patch_operation.rb', line 19 def self.parse_request(body) ops = body["Operations"] || body["operations"] || [] ops.map { |op_hash| parse(op_hash) } end |