Module: Scjson::Types::TransitionTypeDatatypeProps

Defined in:
lib/scjson/types.rb

Overview

The type of the transition i.e. internal or external.

Constant Summary collapse

INTERNAL =
'internal'.freeze
EXTERNAL =
'external'.freeze
DEFAULT =
INTERNAL
VALUES =
[INTERNAL, EXTERNAL].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)


213
214
215
216
217
218
219
220
221
# File 'lib/scjson/types.rb', line 213

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

.defaultString

Returns Schema-defined default enumeration value.

Returns:

  • (String)

    Schema-defined default enumeration value.



205
206
207
# File 'lib/scjson/types.rb', line 205

def default
  DEFAULT
end

.valuesArray<String>

Returns All legal enumeration values.

Returns:

  • (Array<String>)

    All legal enumeration values.



200
201
202
# File 'lib/scjson/types.rb', line 200

def values
  VALUES
end