Class: Scim::Kit::V2::Resource

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

Overview

Represents a SCIM Resource

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(schemas:, location: nil) {|_self| ... } ⇒ Resource

Returns a new instance of Resource.

Yields:

  • (_self)

Yield Parameters:



19
20
21
22
23
24
25
26
27
# File 'lib/scim/kit/v2/resource.rb', line 19

def initialize(schemas:, location: nil)
  @meta = Meta.new(schemas[0].name, location)
  @meta.disable_timestamps
  @schemas = schemas
  schemas.each do |schema|
    define_attributes_for(self, schema.attributes)
  end
  yield self if block_given?
end

Instance Attribute Details

#external_idObject

Returns the value of attribute external_id.



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

def external_id
  @external_id
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#metaObject (readonly)

Returns the value of attribute meta.



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

def meta
  @meta
end

#schemasObject (readonly)

Returns the value of attribute schemas.



14
15
16
# File 'lib/scim/kit/v2/resource.rb', line 14

def schemas
  @schemas
end

Instance Method Details

#mode?(type) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
# File 'lib/scim/kit/v2/resource.rb', line 29

def mode?(type)
  case type.to_sym
  when :server
    meta&.location
  else
    meta&.location.nil?
  end
end