Commit 5385715
Changed files (2)
lib
scim
lib/scim/kit/v2/service_provider_configuration.rb
@@ -6,10 +6,10 @@ module Scim
# Represents a scim Service Provider Configuration
class ServiceProviderConfiguration
include Templatable
+ attr_accessor :bulk, :filter
+ attr_accessor :etag, :sort, :change_password, :patch
attr_accessor :meta, :documentation_uri
attr_reader :authentication_schemes
- attr_reader :bulk, :filter
- attr_reader :etag, :sort, :change_password, :patch
def initialize(location:)
@meta = Meta.new('ServiceProviderConfig', location)
@@ -34,15 +34,9 @@ module Scim
x = new(location: hash[:location])
x.meta = Meta.from(hash[:meta])
x.documentation_uri = hash[:documentationUri]
- x.bulk.supported = hash[:bulk][:supported]
- x.bulk.max_operations = hash[:bulk][:maxOperations]
- x.bulk.max_payload_size = hash[:bulk][:maxPayloadSize]
- x.filter.supported = hash[:filter][:supported]
- x.filter.max_results = hash[:filter][:maxResults]
- x.patch.supported = hash[:patch][:supported]
- x.change_password.supported = hash[:changePassword][:supported]
- x.sort.supported = hash[:sort][:supported]
- x.etag.supported = hash[:etag][:supported]
+ %i[patch changePassword sort etag filter bulk].each do |key|
+ x.send("#{key.to_s.underscore}=", Supportable.from(hash[key]))
+ end
hash[:authenticationSchemes]&.each do |auth|
x.authentication_schemes << AuthenticationScheme.from(auth)
end
lib/scim/kit/v2/supportable.rb
@@ -11,11 +11,22 @@ module Scim
attr_accessor :supported
def initialize(*dynamic_attributes)
+ dynamic_attributes.delete(:supported)
@dynamic_attributes = Hash[
dynamic_attributes.map { |x| ["#{x}=".to_sym, nil] }
]
@supported = false
end
+
+ class << self
+ def from(hash)
+ x = new(*hash.keys)
+ hash.each do |key, value|
+ x.public_send("#{key}=", value)
+ end
+ x
+ end
+ end
end
end
end