Commit 0b7b891

mo <mo.khan@gmail.com>
2019-01-08 04:11:12
underscore the attribute type name tag: v0.2.2
1 parent 0d82fb5
lib/scim/kit/v2/templates/resource.json.jbuilder
@@ -10,12 +10,12 @@ end
 schemas.each do |schema|
   if schema.core?
     schema.attributes.each do |type|
-      render dynamic_attributes[type.name.underscore], json: json
+      render dynamic_attributes[type.name], json: json
     end
   else
     json.set! schema.id do
       schema.attributes.each do |type|
-        render dynamic_attributes[type.name.underscore], json: json
+        render dynamic_attributes[type.name], json: json
       end
     end
   end
lib/scim/kit/v2/attributable.rb
@@ -10,7 +10,7 @@ module Scim
         def define_attributes_for(types)
           @dynamic_attributes = {}.with_indifferent_access
           types.each do |type|
-            dynamic_attributes[type.name.underscore] = Attribute.new(type: type)
+            dynamic_attributes[type.name] = Attribute.new(type: type)
             extend(create_module_for(type))
           end
         end
@@ -33,7 +33,7 @@ module Scim
         end
 
         def create_module_for(type)
-          name = type.name.underscore.to_sym
+          name = type.name.to_sym
           Module.new do
             define_method(name) do |*_args|
               read_attribute(name)
lib/scim/kit/v2/attribute_type.rb
@@ -35,7 +35,7 @@ module Scim
         attr_reader :uniqueness
 
         def initialize(name:, type: :string)
-          @name = name.to_s
+          @name = name.to_s.underscore
           @type = type.to_sym
           @description = ''
           @multi_valued = false
spec/scim/kit/v2/attribute_type_spec.rb
@@ -15,9 +15,9 @@ RSpec.describe Scim::Kit::V2::AttributeType do
     describe 'defaults' do
       subject { described_class.new(name: 'displayName') }
 
-      specify { expect(subject.name).to eql('displayName') }
+      specify { expect(subject.name).to eql('display_name') }
       specify { expect(subject.type).to be(:string) }
-      specify { expect(subject.to_h[:name]).to eql('displayName') }
+      specify { expect(subject.to_h[:name]).to eql('display_name') }
       specify { expect(subject.to_h[:type]).to eql('string') }
       specify { expect(subject.to_h[:multiValued]).to be(false) }
       specify { expect(subject.to_h[:description]).to eql('') }
spec/scim/kit/v2/schema_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Scim::Kit::V2::Schema do
       subject.add_attribute(name: 'displayName')
     end
 
-    specify { expect(result[:attributes][0][:name]).to eql('displayName') }
+    specify { expect(result[:attributes][0][:name]).to eql('display_name') }
     specify { expect(result[:attributes][0][:type]).to eql('string') }
     specify { expect(result[:attributes][0][:multiValued]).to be(false) }
     specify { expect(result[:attributes][0][:description]).to eql('') }