Commit c32d90d
Changed files (3)
lib
scim
kit
lib/scim/kit/v2/attribute_type.rb
@@ -85,6 +85,20 @@ module Scim
complex? ? valid_complex?(value) : valid_simple?(value)
end
+ def self.from(hash)
+ new(name: hash[:name], type: hash[:type]).tap do |x|
+ x.canonical_values = hash[:canonicalValues]
+ x.case_exact = hash[:caseExact]
+ x.description = hash[:description]
+ x.multi_valued = hash[:multiValued]
+ x.mutability = hash[:mutability]
+ x.reference_types = hash[:referenceTypes]
+ x.required = hash[:required]
+ x.returned = hash[:returned]
+ x.uniqueness = hash[:uniqueness]
+ end
+ end
+
private
def coerce_single(value)
lib/scim/kit/v2/meta.rb
@@ -24,10 +24,16 @@ module Scim
def self.from(hash)
meta = Meta.new(hash[:resourceType], hash[:location])
- meta.created = DateTime.parse(hash[:created]) if hash[:created]
- if hash[:lastModified]
- meta.last_modified = DateTime.parse(hash[:lastModified])
- end
+ meta.created = begin
+ DateTime.parse(hash[:created])
+ rescue StandardError
+ nil
+ end
+ meta.last_modified = begin
+ DateTime.parse(hash[:lastModified])
+ rescue StandardError
+ nil
+ end
meta.version = hash[:version]
meta
end
lib/scim/kit/v2/schema.rb
@@ -45,17 +45,7 @@ module Scim
) do |x|
x.meta = Meta.from(hash[:meta])
hash[:attributes].each do |attr|
- x.add_attribute(name: attr[:name], type: attr[:type]) do |y|
- y.description = attr[:description]
- y.multi_valued = attr[:multiValued]
- y.required = attr[:required]
- y.case_exact = attr[:caseExact]
- y.mutability = attr[:mutability]
- y.returned = attr[:returned]
- y.uniqueness = attr[:uniqueness]
- y.canonical_values = attr[:canonicalValues]
- y.reference_types = attr[:referenceTypes]
- end
+ x.attributes << AttributeType.from(attr)
end
end
end