Sha256: 79827ef93923a5f270970e5367c9870b45534bf04b21bfb695718b444d192534

Contents?: true

Size: 884 Bytes

Versions: 2

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

module Scim
  module Kit
    module V2
      # Represents a SCIM Schema
      class Schema
        include Templatable

        attr_reader :id, :name, :attributes, :meta
        attr_accessor :description

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scim-kit-0.2.6 lib/scim/kit/v2/schema.rb
scim-kit-0.2.5 lib/scim/kit/v2/schema.rb