Module: Scjson::Types::ExmodeDatatypeProps

Defined in:
lib/scjson/types.rb

Overview

Describes the processor execution mode for this document, being either “lax” or “strict”.

Constant Summary collapse

LAX =
'lax'.freeze
STRICT =
'strict'.freeze
DEFAULT =
LAX
VALUES =
[LAX, STRICT].freeze

Class Method Summary collapse

Class Method Details

.coerce(value, allow_nil: false) ⇒ String?

Coerce arbitrary input into a valid enumeration value.

Parameters:

  • value (Object, nil)

    Raw value to coerce.

  • allow_nil (Boolean) (defaults to: false)

    When true, allow nil to pass-through.

Returns:

  • (String, nil)

Raises:

  • (ArgumentError)


145
146
147
148
149
150
151
152
153
# File 'lib/scjson/types.rb', line 145

def coerce(value, allow_nil: false)
  return nil if allow_nil && value.nil?
  return DEFAULT if value.nil?

  candidate = value.to_s
  return candidate if VALUES.include?(candidate)

  raise ArgumentError, "Unsupported value '#{value}' for ExmodeDatatypeProps"
end

.defaultString

Returns Schema-defined default enumeration value.

Returns:

  • (String)

    Schema-defined default enumeration value.



137
138
139
# File 'lib/scjson/types.rb', line 137

def default
  DEFAULT
end

.valuesArray<String>

Returns All legal enumeration values.

Returns:

  • (Array<String>)

    All legal enumeration values.



132
133
134
# File 'lib/scjson/types.rb', line 132

def values
  VALUES
end