Class: ScimEngine::ResourceType

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/scim_engine/resource_type.rb

Overview

Provides info about a resource type. Instances of this class are used to provide info through the /ResourceTypes endpoint of a SCIM service provider.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ResourceType

Returns a new instance of ResourceType.



7
8
9
10
11
12
13
14
15
# File 'app/models/scim_engine/resource_type.rb', line 7

def initialize(attributes = {})
  default_attributes = {
    meta: Meta.new(
      'resourceType': 'ResourceType'
    ),
    schemas: ['urn:ietf:params:scim:schemas:core:2.0:ResourceType']
  }
  super(default_attributes.merge(attributes))
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def endpoint
  @endpoint
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def id
  @id
end

#metaObject

Returns the value of attribute meta.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def meta
  @meta
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def name
  @name
end

#schemaObject

Returns the value of attribute schema.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def schema
  @schema
end

#schemaExtensionsObject

Returns the value of attribute schemaExtensions.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def schemaExtensions
  @schemaExtensions
end

#schemasObject

Returns the value of attribute schemas.



5
6
7
# File 'app/models/scim_engine/resource_type.rb', line 5

def schemas
  @schemas
end

Instance Method Details

#as_json(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/models/scim_engine/resource_type.rb', line 18

def as_json(options = {})
  without_extensions = super(except: 'schemaExtensions')
  if schemaExtensions.present?
    extensions = schemaExtensions.map{|extension| {"schema" => extension, "required" => false}}
    without_extensions.merge('schemaExtensions' => extensions)
  else
    without_extensions
  end
end