Class: Scim::Kit::V2::Attribute
- Inherits:
-
Object
- Object
- Scim::Kit::V2::Attribute
- Includes:
- ActiveModel::Validations, Templatable, Attributable
- Defined in:
- lib/scim/kit/v2/attribute.rb
Overview
Represents a SCIM Attribute
Instance Attribute Summary collapse
-
#_resource ⇒ Object
readonly
Returns the value of attribute _resource.
-
#_type ⇒ Object
readonly
Returns the value of attribute _type.
-
#_value ⇒ Object
Returns the value of attribute _value.
Instance Method Summary collapse
- #_assign(new_value, coerce: true) ⇒ Object
-
#initialize(resource:, type:, value: nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #renderable? ⇒ Boolean
Methods included from Templatable
#as_json, #render, #template_name, #to_h, #to_json
Methods included from Attributable
#assign_attributes, #define_attributes_for, #dynamic_attributes
Constructor Details
#initialize(resource:, type:, value: nil) ⇒ Attribute
Returns a new instance of Attribute.
19 20 21 22 23 24 |
# File 'lib/scim/kit/v2/attribute.rb', line 19 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
#_resource ⇒ Object (readonly)
Returns the value of attribute _resource.
12 13 14 |
# File 'lib/scim/kit/v2/attribute.rb', line 12 def _resource @_resource end |
#_type ⇒ Object (readonly)
Returns the value of attribute _type.
11 12 13 |
# File 'lib/scim/kit/v2/attribute.rb', line 11 def _type @_type end |
#_value ⇒ Object
Returns the value of attribute _value.
13 14 15 |
# File 'lib/scim/kit/v2/attribute.rb', line 13 def _value @_value end |
Instance Method Details
#_assign(new_value, coerce: true) ⇒ Object
26 27 28 |
# File 'lib/scim/kit/v2/attribute.rb', line 26 def _assign(new_value, coerce: true) @_value = coerce ? _type.coerce(new_value) : new_value end |
#renderable? ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/scim/kit/v2/attribute.rb', line 34 def renderable? return false if server_only? return false if client_only? return false if restricted? true end |