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

Attributes included from Attributable

#dynamic_attributes

Instance Method Summary collapse

Methods included from Templatable

#as_json, #render, #to_h, #to_json

Methods included from Attributable

#define_attributes_for

Constructor Details

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

Returns a new instance of Attribute.



18
19
20
21
22
# File 'lib/scim/kit/v2/attribute.rb', line 18

def initialize(type:, value: nil)
  @type = type
  @_value = value
  define_attributes_for(type.attributes)
end

Instance Attribute Details

#_valueObject

Returns the value of attribute _value.



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

def _value
  @_value
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#_assign(new_value, coerce: true) ⇒ Object



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

def _assign(new_value, coerce: true)
  @_value = coerce ? type.coerce(new_value) : new_value
end