Module: Scjson::Types::HistoryTypeDatatypeProps

Defined in:
lib/scjson/types.rb

Overview

type of ‘<history>` state: `shallow` or `deep`.

Constant Summary collapse

SHALLOW =
'shallow'.freeze
DEEP =
'deep'.freeze
DEFAULT =
SHALLOW
VALUES =
[SHALLOW, DEEP].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)


179
180
181
182
183
184
185
186
187
# File 'lib/scjson/types.rb', line 179

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 HistoryTypeDatatypeProps"
end

.defaultString

Returns Schema-defined default enumeration value.

Returns:

  • (String)

    Schema-defined default enumeration value.



171
172
173
# File 'lib/scjson/types.rb', line 171

def default
  DEFAULT
end

.valuesArray<String>

Returns All legal enumeration values.

Returns:

  • (Array<String>)

    All legal enumeration values.



166
167
168
# File 'lib/scjson/types.rb', line 166

def values
  VALUES
end