Module: Candid::Internal::Types::Type Abstract

Includes:
JSON::Serializable
Included in:
Array, Enum, Hash, Model, Union, Unknown
Defined in:
lib/candid/internal/types/type.rb

Overview

This module is abstract.

Instance Method Summary collapse

Methods included from JSON::Serializable

#dump, #load

Instance Method Details

#coerce(value, strict: strict?) ) ⇒ Object

Coerces a value to this type

Options Hash (strict:):

  • If (Boolean)

    we should strictly coerce this value

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/candid/internal/types/type.rb', line 14

def coerce(value, strict: strict?)
  raise NotImplementedError
end

#strict!void

This method returns an undefined value.

Enable strictness by default for this type



28
29
30
31
# File 'lib/candid/internal/types/type.rb', line 28

def strict!
  @strict = true
  self
end

#strict?Boolean

Returns if strictness is on for this type, defaults to ‘false`



21
22
23
# File 'lib/candid/internal/types/type.rb', line 21

def strict?
  @strict ||= false
end