Commit be448b4

mokha <mokha@cisco.com>
2019-01-07 17:00:13
allow resources to support complex types
1 parent ed792bf
Changed files (3)
lib/scim/kit/v2/attributable.rb
@@ -19,7 +19,8 @@ module Scim
 
             @dynamic_attributes[target].value = args[0]
           else
-            @dynamic_attributes[method].value
+            attribute = @dynamic_attributes[method]
+            attribute.type.complex? ? @dynamic_attributes[method] : @dynamic_attributes[method].value
           end
         end
 
lib/scim/kit/v2/attribute_type.rb
@@ -68,12 +68,12 @@ module Scim
           @attributes ||= []
         end
 
-        private
-
         def complex?
           type_is?(:complex)
         end
 
+        private
+
         def string?
           type_is?(:string)
         end
spec/scim/kit/v2/resource_spec.rb
@@ -50,4 +50,18 @@ RSpec.describe Scim::Kit::V2::Resource do
 
     specify { expect(subject.user_name).to eql(user_name) }
   end
+
+  context 'with a complex attribute' do
+    before do
+      schema.add_attribute(name: 'name') do |x|
+        x.add_attribute(name: 'familyName')
+        x.add_attribute(name: 'givenName')
+      end
+      subject.name.family_name = 'khan'
+      subject.name.given_name = 'mo'
+    end
+
+    specify { expect(subject.name.family_name).to eql('khan') }
+    specify { expect(subject.name.given_name).to eql('mo') }
+  end
 end