Commit f891efc

mo khan <mo@mokhan.ca>
2022-12-09 17:25:45
feat: provide optional schema to AttributeType
1 parent a668391
Changed files (2)
lib/scim/kit/v2/attribute_type.rb
@@ -10,10 +10,12 @@ module Scim
         attr_accessor :multi_valued, :required
         attr_reader :mutability, :name, :type, :attributes
         attr_reader :reference_types, :returned, :uniqueness
+        attr_reader :schema
 
-        def initialize(name:, type: :string)
+        def initialize(name:, type: :string, schema: nil)
           @name = name.to_s.underscore
           @type = DATATYPES[type.to_sym] ? type.to_sym : (raise TYPE_ERROR)
+          @schema = schema
           @description = name.to_s.camelize(:lower)
           @multi_valued = false
           @required = false
lib/scim/kit/v2/schema.rb
@@ -21,7 +21,7 @@ module Scim
         end
 
         def add_attribute(name:, type: :string)
-          attribute = AttributeType.new(name: name, type: type)
+          attribute = AttributeType.new(name: name, type: type, schema: self)
           yield attribute if block_given?
           attributes << attribute
         end