Commit ecb79b7

mokha <mokha@cisco.com>
2019-01-18 17:42:09
define attributes for id an external_id
1 parent 87b24ad
Changed files (2)
lib/scim/kit/v2/attributable.rb
@@ -5,10 +5,11 @@ module Scim
     module V2
       # Represents a dynamic attribute that corresponds to a SCIM type
       module Attributable
-        attr_reader :dynamic_attributes
+        def dynamic_attributes
+          @dynamic_attributes ||= {}.with_indifferent_access
+        end
 
         def define_attributes_for(resource, types)
-          @dynamic_attributes ||= {}.with_indifferent_access
           types.each { |x| attribute(x, resource) }
         end
 
lib/scim/kit/v2/resource.rb
@@ -9,7 +9,6 @@ module Scim
         include Attributable
         include Templatable
 
-        attr_accessor :id, :external_id
         attr_reader :meta
         attr_reader :schemas
         attr_reader :raw_attributes
@@ -21,9 +20,9 @@ module Scim
           @meta.disable_timestamps
           @schemas = schemas
           @raw_attributes = attributes
-          schemas.each do |schema|
-            define_attributes_for(self, schema.attributes)
-          end
+          schemas.each { |x| define_attributes_for(self, x.attributes) }
+          attribute(AttributeType.new(name: :id), self)
+          attribute(AttributeType.new(name: :external_id), self)
           assign_attributes(attributes)
           yield self if block_given?
         end