Class: Scim::Kit::V2::AttributeType

Inherits:
Object
  • Object
show all
Includes:
Templatable
Defined in:
lib/scim/kit/v2/attribute_type.rb

Overview

Represents a scim Attribute type

Constant Summary collapse

DATATYPES =
{
  string: 'string',
  boolean: 'boolean',
  decimal: 'decimal',
  integer: 'integer',
  datetime: 'dateTime',
  binary: 'binary',
  reference: 'reference',
  complex: 'complex'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Templatable

#as_json, #render, #to_h, #to_json

Constructor Details

#initialize(name:, type: :string) ⇒ AttributeType

Returns a new instance of AttributeType.

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/scim/kit/v2/attribute_type.rb', line 30

def initialize(name:, type: :string)
  @name = name
  @type = type
  @description = ''
  @multi_valued = false
  @required = false
  @case_exact = false
  @mutability = Mutability::READ_WRITE
  @returned = Returned::DEFAULT
  @uniqueness = Uniqueness::NONE
  raise ArgumentError, :type unless DATATYPES[type.to_sym]
end

Instance Attribute Details

#canonical_valuesObject

Returns the value of attribute canonical_values.



19
20
21
# File 'lib/scim/kit/v2/attribute_type.rb', line 19

def canonical_values
  @canonical_values
end

#case_exactObject

Returns the value of attribute case_exact.



20
21
22
# File 'lib/scim/kit/v2/attribute_type.rb', line 20

def case_exact
  @case_exact
end

#descriptionObject

Returns the value of attribute description.



21
22
23
# File 'lib/scim/kit/v2/attribute_type.rb', line 21

def description
  @description
end

#multi_valuedObject

Returns the value of attribute multi_valued.



22
23
24
# File 'lib/scim/kit/v2/attribute_type.rb', line 22

def multi_valued
  @multi_valued
end

#mutabilityObject

Returns the value of attribute mutability.



24
25
26
# File 'lib/scim/kit/v2/attribute_type.rb', line 24

def mutability
  @mutability
end

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/scim/kit/v2/attribute_type.rb', line 25

def name
  @name
end

#reference_typesObject

Returns the value of attribute reference_types.



26
27
28
# File 'lib/scim/kit/v2/attribute_type.rb', line 26

def reference_types
  @reference_types
end

#requiredObject

Returns the value of attribute required.



23
24
25
# File 'lib/scim/kit/v2/attribute_type.rb', line 23

def required
  @required
end

#returnedObject

Returns the value of attribute returned.



27
28
29
# File 'lib/scim/kit/v2/attribute_type.rb', line 27

def returned
  @returned
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/scim/kit/v2/attribute_type.rb', line 25

def type
  @type
end

#uniquenessObject

Returns the value of attribute uniqueness.



28
29
30
# File 'lib/scim/kit/v2/attribute_type.rb', line 28

def uniqueness
  @uniqueness
end

Instance Method Details

#add_attribute(name:, type: :string) {|attribute| ... } ⇒ Object

Yields:

  • (attribute)


55
56
57
58
59
60
# File 'lib/scim/kit/v2/attribute_type.rb', line 55

def add_attribute(name:, type: :string)
  @type = :complex
  attribute = AttributeType.new(name: name, type: type)
  yield attribute if block_given?
  attributes << attribute
end