class Scim::Kit::V2::Schema

Represents a SCIM Schema

Attributes

attributes[R]
description[RW]
id[R]
meta[RW]
name[R]

Public Class Methods

build(*args) { |item| ... } click to toggle source
# File lib/scim/kit/v2/schema.rb, line 34
def build(*args)
  item = new(*args)
  yield item
  item
end
from(hash) click to toggle source
# File lib/scim/kit/v2/schema.rb, line 40
def from(hash)
  Schema.new(
    id: hash[:id],
    name: hash[:name],
    location: hash[:location]
  ) do |x|
    x.meta = Meta.from(hash[:meta])
    hash[:attributes].each do |y|
      x.attributes << AttributeType.from(y)
    end
  end
end
new(id:, name:, location:) { |self| ... } click to toggle source
# 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
parse(json) click to toggle source
# File lib/scim/kit/v2/schema.rb, line 53
def parse(json)
  from(JSON.parse(json, symbolize_names: true))
end

Public Instance Methods

add_attribute(name:, type: :string) { |attribute| ... } click to toggle source
# 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?() click to toggle source
# File lib/scim/kit/v2/schema.rb, line 29
def core?
  id.include?(Schemas::CORE) || id.include?(Messages::CORE)
end