Class: Scim::Kit::V2::Schema

Inherits:
Object
  • Object
show all
Includes:
Templatable
Defined in:
lib/scim/kit/v2/schema.rb

Overview

Represents a SCIM Schema

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Templatable

#as_json, #render, #template_name, #to_h, #to_json

Constructor Details

#initialize(id:, name:, location:) {|_self| ... } ⇒ Schema

Returns a new instance of Schema.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
20
21
# File 'lib/scim/kit/v2/schema.rb', line 13

def initialize(id:, name:, location:)
  @id = id
  @name = name
  @description = name
  @meta = Meta.new('Schema', location)
  @meta.created = @meta.last_modified = @meta.version = nil
  @attributes = []
  yield self if block_given?
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/scim/kit/v2/schema.rb', line 10

def attributes
  @attributes
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/scim/kit/v2/schema.rb', line 11

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/scim/kit/v2/schema.rb', line 10

def id
  @id
end

#metaObject (readonly)

Returns the value of attribute meta.



10
11
12
# File 'lib/scim/kit/v2/schema.rb', line 10

def meta
  @meta
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/scim/kit/v2/schema.rb', line 10

def name
  @name
end

Class Method Details

.build(*args) {|item| ... } ⇒ Object

Yields:

  • (item)


33
34
35
36
37
# File 'lib/scim/kit/v2/schema.rb', line 33

def self.build(*args)
  item = new(*args)
  yield item
  item
end

Instance Method Details

#add_attribute(name:, type: :string) {|attribute| ... } ⇒ Object

Yields:

  • (attribute)


23
24
25
26
27
# File 'lib/scim/kit/v2/schema.rb', line 23

def add_attribute(name:, type: :string)
  attribute = AttributeType.new(name: name, type: type)
  yield attribute if block_given?
  attributes << attribute
end

#core?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/scim/kit/v2/schema.rb', line 29

def core?
  id.include?(Schemas::CORE) || id.include?(Messages::CORE)
end