Module: Scjson::Types::AssignTypeDatatypeProps

Defined in:
lib/scjson/types.rb

Overview

The assign type that allows for precise manipulation of the datamodel location. Types are: replacechildren (default), firstchild, lastchild, previoussibling, nextsibling, replace, delete, addattribute

Constant Summary collapse

REPLACECHILDREN =
'replacechildren'.freeze
FIRSTCHILD =
'firstchild'.freeze
LASTCHILD =
'lastchild'.freeze
PREVIOUSSIBLING =
'previoussibling'.freeze
NEXTSIBLING =
'nextsibling'.freeze
REPLACE =
'replace'.freeze
DELETE =
'delete'.freeze
ADDATTRIBUTE =
'addattribute'.freeze
DEFAULT =
REPLACECHILDREN
VALUES =
[REPLACECHILDREN, FIRSTCHILD, LASTCHILD, PREVIOUSSIBLING, NEXTSIBLING, REPLACE, DELETE, ADDATTRIBUTE].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)


43
44
45
46
47
48
49
50
51
# File 'lib/scjson/types.rb', line 43

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

.defaultString

Returns Schema-defined default enumeration value.

Returns:

  • (String)

    Schema-defined default enumeration value.



35
36
37
# File 'lib/scjson/types.rb', line 35

def default
  DEFAULT
end

.valuesArray<String>

Returns All legal enumeration values.

Returns:

  • (Array<String>)

    All legal enumeration values.



30
31
32
# File 'lib/scjson/types.rb', line 30

def values
  VALUES
end