Module: Scim::Kit::V2

Defined in:
lib/scim/kit/v2.rb,
lib/scim/kit/v2/meta.rb,
lib/scim/kit/v2/error.rb,
lib/scim/kit/v2/filter.rb,
lib/scim/kit/v2/schema.rb,
lib/scim/kit/v2/schemas.rb,
lib/scim/kit/v2/messages.rb,
lib/scim/kit/v2/resource.rb,
lib/scim/kit/v2/returned.rb,
lib/scim/kit/v2/attribute.rb,
lib/scim/kit/v2/mutability.rb,
lib/scim/kit/v2/uniqueness.rb,
lib/scim/kit/v2/filter/node.rb,
lib/scim/kit/v2/supportable.rb,
lib/scim/kit/v2/attributable.rb,
lib/scim/kit/v2/configuration.rb,
lib/scim/kit/v2/resource_type.rb,
lib/scim/kit/v2/attribute_type.rb,
lib/scim/kit/v2/filter/visitor.rb,
lib/scim/kit/v2/unknown_attribute.rb,
lib/scim/kit/v2/authentication_scheme.rb,
lib/scim/kit/v2/complex_attribute_validator.rb,
lib/scim/kit/v2/service_provider_configuration.rb

Overview

Version 2 of the SCIM RFC tools.ietf.org/html/rfc7644

Defined Under Namespace

Modules: Attributable, Messages, Schemas Classes: Attribute, AttributeType, AuthenticationScheme, ComplexAttributeValidator, Configuration, Error, Filter, Meta, Mutability, Resource, ResourceType, Returned, Schema, ServiceProviderConfiguration, Supportable, Uniqueness, UnknownAttribute

Constant Summary collapse

BASE64 =
%r(
  \A([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\Z
)x
BOOLEAN_VALUES =
[true, false].freeze
DATATYPES =
{
  string: 'string',
  boolean: 'boolean',
  decimal: 'decimal',
  integer: 'integer',
  datetime: 'dateTime',
  binary: 'binary',
  reference: 'reference',
  complex: 'complex'
}.freeze
COERCION =
{
  binary: lambda { |x|
    VALIDATIONS[:binary].call(x) ? x : Base64.strict_encode64(x)
  },
  boolean: lambda { |x|
    return true if x == 'true'
    return false if x == 'false'

    x
  },
  datetime: ->(x) { x.is_a?(::String) ? DateTime.parse(x) : x },
  decimal: ->(x) { x.to_f },
  integer: ->(x) { x.to_i },
  string: ->(x) { x.to_s }
}.freeze
VALIDATIONS =
{
  binary: ->(x) { x.is_a?(String) && x.match?(BASE64) },
  boolean: ->(x) { BOOLEAN_VALUES.include?(x) },
  datetime: ->(x) { x.is_a?(DateTime) },
  decimal: ->(x) { x.is_a?(Float) },
  integer: lambda { |x|
    begin
      x&.integer?
    rescue StandardError
      false
    end
  },
  reference: ->(x) { x&.to_s =~ /\A#{URI::DEFAULT_PARSER.make_regexp(%w[http https])}\z/ },
  string: ->(x) { x.is_a?(String) }
}.freeze

Class Method Summary collapse

Class Method Details

.configurationObject



76
77
78
# File 'lib/scim/kit/v2.rb', line 76

def configuration
  @configuration ||= ::Scim::Kit::V2::Configuration.new
end

.configure {|::Scim::Kit::V2::Configuration::Builder.new(configuration)| ... } ⇒ Object



80
81
82
# File 'lib/scim/kit/v2.rb', line 80

def configure
  yield ::Scim::Kit::V2::Configuration::Builder.new(configuration)
end