diff options
| author | mo <mo.khan@gmail.com> | 2019-01-07 21:11:12 -0700 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-01-07 21:11:12 -0700 |
| commit | 0b7b891dbd117a4456861b23e6b6c8f90c673498 (patch) | |
| tree | 2d7b1a050c1bfe45ffc7608e0ef0ca7fe8f8c83a | |
| parent | 0d82fb5bfa31e96a55d8b374d52620815553d2cf (diff) | |
underscore the attribute type namev0.2.2
| -rw-r--r-- | lib/scim/kit/v2/attributable.rb | 4 | ||||
| -rw-r--r-- | lib/scim/kit/v2/attribute_type.rb | 2 | ||||
| -rw-r--r-- | lib/scim/kit/v2/templates/resource.json.jbuilder | 4 | ||||
| -rw-r--r-- | spec/scim/kit/v2/attribute_type_spec.rb | 4 | ||||
| -rw-r--r-- | spec/scim/kit/v2/schema_spec.rb | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/lib/scim/kit/v2/attributable.rb b/lib/scim/kit/v2/attributable.rb index 83ebf3a..6d46e3b 100644 --- a/lib/scim/kit/v2/attributable.rb +++ b/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) diff --git a/lib/scim/kit/v2/attribute_type.rb b/lib/scim/kit/v2/attribute_type.rb index 5103e42..19ecfde 100644 --- a/lib/scim/kit/v2/attribute_type.rb +++ b/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 diff --git a/lib/scim/kit/v2/templates/resource.json.jbuilder b/lib/scim/kit/v2/templates/resource.json.jbuilder index d08330e..5b31825 100644 --- a/lib/scim/kit/v2/templates/resource.json.jbuilder +++ b/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 diff --git a/spec/scim/kit/v2/attribute_type_spec.rb b/spec/scim/kit/v2/attribute_type_spec.rb index dba970d..db4c060 100644 --- a/spec/scim/kit/v2/attribute_type_spec.rb +++ b/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('') } diff --git a/spec/scim/kit/v2/schema_spec.rb b/spec/scim/kit/v2/schema_spec.rb index f319028..5e821db 100644 --- a/spec/scim/kit/v2/schema_spec.rb +++ b/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('') } |
