scim-kit 0.2.14 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbc81233afe702bcd1a1288da763ff6427ecd3f43960d7f929b608434f617a1f
4
- data.tar.gz: 7973302adf611f0bde1ecbb4a47f7d9214763f6c7ee15e6c23af697fc27dfe02
3
+ metadata.gz: 29f7f31b1bd1883c5596ae65c31154ccc5a677e3544b99bc1b094a5d642cabe3
4
+ data.tar.gz: 7410afff1d62abb9707de138964af6c05cfb144be5b81391f6c8d16a36bbb730
5
5
  SHA512:
6
- metadata.gz: 72fd293f278e2d2c8ffbcdb63f871d27d47e919df333abab4db973ce8a350c7cfb600f505cfb25a56185485406ad11b605e5e53dc80b53eed49b26b754a7b5eb
7
- data.tar.gz: 16c34302e8ff58c54d4fc22043bad37aea6f8f050d75f1c2c7ac7165f8f51bd84aa89472c4e55cded70a4beebebaf239661b8e1e87c3f3799d0b8808b3a9b069
6
+ metadata.gz: e160792a08bd353d7e7b087a3bccb1ee858bfc1b049c56f74d00d5965a37b7a71f5b7761ba5173a67bba7e51489eca37e8fafd67c2489fe73aafb3b9196ad9c2
7
+ data.tar.gz: 218155f337f9d0f2ce1a989208ec9368be426d25f691bcda9bb437a130251bd53e9f0c3e09bda6743bc604311cdb6385fd9604c4b60ffa680607473ab9d32448
@@ -5,10 +5,11 @@ module Scim
5
5
  module V2
6
6
  # Represents a dynamic attribute that corresponds to a SCIM type
7
7
  module Attributable
8
- attr_reader :dynamic_attributes
8
+ def dynamic_attributes
9
+ @dynamic_attributes ||= {}.with_indifferent_access
10
+ end
9
11
 
10
12
  def define_attributes_for(resource, types)
11
- @dynamic_attributes ||= {}.with_indifferent_access
12
13
  types.each { |x| attribute(x, resource) }
13
14
  end
14
15
 
@@ -41,7 +42,10 @@ module Scim
41
42
  if value.is_a?(Hash)
42
43
  attribute_for(name)&.assign_attributes(value)
43
44
  else
44
- attribute_for(name)&._value = value
45
+ attribute = attribute_for(name)
46
+ raise Scim::Kit::UnknownAttributeError, name unless attribute
47
+
48
+ attribute._value = value
45
49
  end
46
50
  end
47
51
 
@@ -12,7 +12,7 @@ module Scim
12
12
  attr_reader :resource_type
13
13
 
14
14
  def initialize(resource_type, location)
15
- @resource_type = resource_type
15
+ @resource_type = resource_type || 'Unknown'
16
16
  @location = location
17
17
  @created = @last_modified = Time.now
18
18
  @version = @created.to_i
@@ -9,7 +9,6 @@ module Scim
9
9
  include Attributable
10
10
  include Templatable
11
11
 
12
- attr_accessor :id, :external_id
13
12
  attr_reader :meta
14
13
  attr_reader :schemas
15
14
  attr_reader :raw_attributes
@@ -17,13 +16,13 @@ module Scim
17
16
  validate :schema_validations
18
17
 
19
18
  def initialize(schemas:, location: nil, attributes: {})
20
- @meta = Meta.new(schemas[0].name, location)
19
+ @meta = Meta.new(schemas[0]&.name, location)
21
20
  @meta.disable_timestamps
22
21
  @schemas = schemas
23
22
  @raw_attributes = attributes
24
- schemas.each do |schema|
25
- define_attributes_for(self, schema.attributes)
26
- end
23
+ schemas.each { |x| define_attributes_for(self, x.attributes) }
24
+ attribute(AttributeType.new(name: :id), self)
25
+ attribute(AttributeType.new(name: :external_id), self)
27
26
  assign_attributes(attributes)
28
27
  yield self if block_given?
29
28
  end
@@ -37,6 +36,10 @@ module Scim
37
36
  end
38
37
  end
39
38
 
39
+ def template_name
40
+ 'resource.json.jbuilder'
41
+ end
42
+
40
43
  private
41
44
 
42
45
  def schema_validations
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Scim
4
4
  module Kit
5
- VERSION = '0.2.14'
5
+ VERSION = '0.2.15'
6
6
  end
7
7
  end
data/lib/scim/kit.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'active_model'
4
4
  require 'active_support/core_ext/hash/indifferent_access'
5
+ require 'json'
6
+ require 'pathname'
5
7
  require 'tilt'
6
8
  require 'tilt/jbuilder'
7
9
 
@@ -14,5 +16,6 @@ require 'scim/kit/version'
14
16
  module Scim
15
17
  module Kit
16
18
  class Error < StandardError; end
19
+ class UnknownAttributeError < Error; end
17
20
  end
18
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scim-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2019-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel