Class: ScimEngine::ComplexTypes::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Errors, Schema::DerivedAttributes
Defined in:
app/models/scim_engine/complex_types/base.rb

Overview

This class represents complex types that could be used inside SCIM resources. Each complex type must inherit from this class. They also need to have their own schema defined.

Examples:

module ScimEngine
  module ComplexTypes
    class Email < Base
      set_schema ScimEngine::Schema::Email

      def as_json(options = {})
        {'type' => 'work', 'primary' => true}.merge(super(options))
      end
    end
  end
end

Direct Known Subclasses

Email, Name, Reference

Instance Method Summary collapse

Methods included from Errors

#add_errors_from_hash

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.


23
24
25
26
# File 'app/models/scim_engine/complex_types/base.rb', line 23

def initialize(options={})
  super
  @errors = ActiveModel::Errors.new(self)
end

Instance Method Details

#as_json(options = {}) ⇒ Object

Converts the object to its SCIM representation which is always a json representation

Parameters:

  • options (Hash) (defaults to: {})

    a hash that could provide default values for some of the attributes of this complex type object


31
32
33
34
# File 'app/models/scim_engine/complex_types/base.rb', line 31

def as_json(options={})
  options[:except] ||= ['errors']
  super.except(options)
end