Commit ce3a824
Changed files (2)
lib
scim
kit
v2
templates
lib/scim/kit/v2/templates/resource_type.json.jbuilder
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+json.key_format! camelize: :lower
+json.meta do
+ json.resource_type 'ResourceType'
+ json.location location
+end
+json.schemas [Scim::Kit::V2::Schema::RESOURCE_TYPE]
+json.id id
+json.name name
+json.description description
+json.endpoint endpoint
+json.schema schema
+json.schema_extensions []
lib/scim/kit/v2/resource_type.rb
@@ -6,6 +6,7 @@ module Scim
# Represents a ResourceType Schema
# https://tools.ietf.org/html/rfc7643#section-6
class ResourceType
+ include Templatable
attr_accessor :id
attr_accessor :name
attr_accessor :description
@@ -17,30 +18,10 @@ module Scim
@location = location
end
- def to_json
- JSON.generate(to_h)
- end
-
- def to_h
- {
- meta: meta,
- schemas: [Schema::RESOURCE_TYPE],
- id: id,
- name: name,
- description: description,
- endpoint: endpoint,
- schema: schema,
- schemaExtensions: []
- }
- end
-
- private
-
- def meta
- {
- resourceType: 'ResourceType',
- location: location
- }
+ def self.build(*args)
+ item = new(*args)
+ yield item
+ item
end
end
end