Class: Scim::Kit::V2::Attribute

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Templatable, Attributable
Defined in:
lib/scim/kit/v2/attribute.rb

Overview

Represents a SCIM Attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Templatable

#as_json, #render, #template_name, #to_h, #to_json

Methods included from Attributable

#assign_attributes, #attribute_for, #define_attributes_for, #dynamic_attributes, #each, #read_attribute, #write_attribute

Constructor Details

#initialize(resource:, type:, value: nil) ⇒ Attribute

Returns a new instance of Attribute.



23
24
25
26
27
28
29
# File 'lib/scim/kit/v2/attribute.rb', line 23

def initialize(resource:, type:, value: nil)
  @_type = type
  @_value = value || type.multi_valued ? [] : nil
  @_resource = resource

  define_attributes_for(resource, type.attributes)
end

Instance Attribute Details

#_resourceObject (readonly)



12
13
14
# File 'lib/scim/kit/v2/attribute.rb', line 12

def _resource
  @_resource
end

#_typeObject (readonly)



11
12
13
# File 'lib/scim/kit/v2/attribute.rb', line 11

def _type
  @_type
end

#_valueObject



13
14
15
# File 'lib/scim/kit/v2/attribute.rb', line 13

def _value
  @_value
end

Instance Method Details

#_assign(new_value, coerce: false) ⇒ Object



31
32
33
# File 'lib/scim/kit/v2/attribute.rb', line 31

def _assign(new_value, coerce: false)
  @_value = coerce ? _type.coerce(new_value) : new_value
end

#each_value(&block) ⇒ Object



47
48
49
# File 'lib/scim/kit/v2/attribute.rb', line 47

def each_value(&block)
  Array(_value).each(&block)
end

#renderable?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
# File 'lib/scim/kit/v2/attribute.rb', line 39

def renderable?
  return false if server_only?
  return false if client_only?
  return false if restricted?

  true
end