Class: Castkit::Types::Collection

Inherits:
Generic
  • Object
show all
Defined in:
lib/castkit/types/collection.rb

Overview

Type definition for ‘:array` attributes.

Wraps any value in an array using ‘Array(value)` coercion. This ensures consistent array representation even if the input is a single value or nil.

This class is used internally by Castkit when an attribute is defined with:

`array :tags, of: :string`

Instance Method Summary collapse

Methods inherited from Generic

cast!, deserialize, serialize, #serialize, validate!, #validate!

Instance Method Details

#deserialize(value) ⇒ ::Array

Deserializes the value into an array using ‘Array(value)`.

Parameters:

  • value (Object)

Returns:

  • (::Array)


19
20
21
# File 'lib/castkit/types/collection.rb', line 19

def deserialize(value)
  Array(value)
end