Class: ScimEngine::Schema::Base
- Inherits:
-
Object
- Object
- ScimEngine::Schema::Base
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/scim_engine/schema/base.rb
Overview
The base class that each schema class must inherit from. These classes represent the schema of a SCIM resource or a complex type that could be used in a resource.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scim_attributes ⇒ Object
Returns the value of attribute scim_attributes.
Class Method Summary collapse
- .cloned_scim_attributes ⇒ Object
-
.valid?(resource) ⇒ Boolean
Validates the resource against specific validations of each attribute,for example if the type of the attribute matches the one defined in the schema.
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ Object
Converts the schema to its json representation that will be returned by /SCHEMAS end-point of a SCIM service provider.
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'app/models/scim_engine/schema/base.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'app/models/scim_engine/schema/base.rb', line 7 def id @id end |
#meta ⇒ Object
Returns the value of attribute meta.
7 8 9 |
# File 'app/models/scim_engine/schema/base.rb', line 7 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'app/models/scim_engine/schema/base.rb', line 7 def name @name end |
#scim_attributes ⇒ Object
Returns the value of attribute scim_attributes.
7 8 9 |
# File 'app/models/scim_engine/schema/base.rb', line 7 def scim_attributes @scim_attributes end |
Class Method Details
.cloned_scim_attributes ⇒ Object
29 30 31 |
# File 'app/models/scim_engine/schema/base.rb', line 29 def self.cloned_scim_attributes scim_attributes.map { |scim_attribute| scim_attribute.clone } end |
.valid?(resource) ⇒ Boolean
Validates the resource against specific validations of each attribute,for example if the type of the attribute matches the one defined in the schema.
23 24 25 26 27 |
# File 'app/models/scim_engine/schema/base.rb', line 23 def self.valid?(resource) cloned_scim_attributes.each do |scim_attribute| resource.add_errors_from_hash(scim_attribute.errors.to_hash) unless scim_attribute.valid?(resource.send(scim_attribute.name)) end end |
Instance Method Details
#as_json(options = {}) ⇒ Object
Converts the schema to its json representation that will be returned by /SCHEMAS end-point of a SCIM service provider.
15 16 17 18 19 |
# File 'app/models/scim_engine/schema/base.rb', line 15 def as_json( = {}) @meta.location = ScimEngine::Engine.routes.url_helpers.scim_schemas_path(name: id) original = super original.merge('attributes' => original.delete('scim_attributes')) end |