scim-kit 0.2.11 → 0.2.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aafb2f3aa6f0b41a4ebde4b089882c524cf66d2e21f235ee052a0c675cc019c8
|
4
|
+
data.tar.gz: dd26edce1bcdde02047b660430ef1621b802f974b6e43575bf438c77c48d2a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc0f4f87fa2e6c74084e8e757ebdceac4ddf8837b11170a0b0a0947aa9637f3af7652b8605bf0c9fad796eef0d1f451f0dd87023f1ce9422cfc3d46c79372a49
|
7
|
+
data.tar.gz: c280082b331cb57b282ff72592e6f0a7b911032b3e2e8840c6b34d812b660817f64afcdb1656d57b26b20af3658420aedc7f96e3a75ee48cf1861f74033aa922
|
@@ -20,9 +20,9 @@ module Scim
|
|
20
20
|
|
21
21
|
def read_attribute(name)
|
22
22
|
attribute = attribute_for(name)
|
23
|
-
return attribute._value if attribute.
|
23
|
+
return attribute._value if attribute._type.multi_valued
|
24
24
|
|
25
|
-
attribute.
|
25
|
+
attribute._type.complex? ? attribute : attribute._value
|
26
26
|
end
|
27
27
|
|
28
28
|
def write_attribute(name, value)
|
@@ -8,23 +8,23 @@ module Scim
|
|
8
8
|
include ::ActiveModel::Validations
|
9
9
|
include Attributable
|
10
10
|
include Templatable
|
11
|
-
attr_reader :
|
11
|
+
attr_reader :_type
|
12
12
|
attr_reader :_resource
|
13
13
|
attr_reader :_value
|
14
14
|
|
15
|
-
validate :presence_of_value, if: proc { |x| x.
|
16
|
-
validate :inclusion_of_value, if: proc { |x| x.
|
15
|
+
validate :presence_of_value, if: proc { |x| x._type.required }
|
16
|
+
validate :inclusion_of_value, if: proc { |x| x._type.canonical_values }
|
17
17
|
validate :validate_type
|
18
18
|
|
19
19
|
def initialize(resource:, type:, value: nil)
|
20
|
-
@
|
20
|
+
@_type = type
|
21
21
|
@_value = value || type.multi_valued ? [] : nil
|
22
22
|
@_resource = resource
|
23
23
|
define_attributes_for(resource, type.attributes)
|
24
24
|
end
|
25
25
|
|
26
26
|
def _assign(new_value, coerce: true)
|
27
|
-
@_value = coerce ?
|
27
|
+
@_value = coerce ? _type.coerce(new_value) : new_value
|
28
28
|
end
|
29
29
|
|
30
30
|
def _value=(new_value)
|
@@ -50,33 +50,33 @@ module Scim
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def restricted?
|
53
|
-
_resource.mode?(:server) &&
|
53
|
+
_resource.mode?(:server) && _type.returned == Returned::NEVER
|
54
54
|
end
|
55
55
|
|
56
56
|
def presence_of_value
|
57
|
-
return unless
|
57
|
+
return unless _type.required && _value.blank?
|
58
58
|
|
59
|
-
errors.add(
|
59
|
+
errors.add(_type.name, I18n.t('errors.messages.blank'))
|
60
60
|
end
|
61
61
|
|
62
62
|
def inclusion_of_value
|
63
|
-
return if
|
63
|
+
return if _type.canonical_values.include?(_value)
|
64
64
|
|
65
|
-
errors.add(
|
65
|
+
errors.add(_type.name, I18n.t('errors.messages.inclusion'))
|
66
66
|
end
|
67
67
|
|
68
68
|
def validate_type
|
69
|
-
return if
|
69
|
+
return if _type.valid?(_value)
|
70
70
|
|
71
|
-
errors.add(
|
71
|
+
errors.add(_type.name, I18n.t('errors.messages.invalid'))
|
72
72
|
end
|
73
73
|
|
74
74
|
def read_only?
|
75
|
-
|
75
|
+
_type.mutability == Mutability::READ_ONLY
|
76
76
|
end
|
77
77
|
|
78
78
|
def write_only?
|
79
|
-
|
79
|
+
_type.mutability == Mutability::WRITE_ONLY
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
json.key_format! camelize: :lower
|
4
|
-
if
|
5
|
-
json.set!
|
4
|
+
if _type.complex? && !_type.multi_valued
|
5
|
+
json.set! _type.name do
|
6
6
|
dynamic_attributes.values.each do |attribute|
|
7
7
|
render attribute, json: json
|
8
8
|
end
|
9
9
|
end
|
10
10
|
elsif renderable?
|
11
|
-
json.set!
|
11
|
+
json.set! _type.name, _value
|
12
12
|
end
|
data/lib/scim/kit/version.rb
CHANGED