Class: Castkit::Types::Collection
- 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
-
#deserialize(value) ⇒ ::Array
Deserializes the value into an array using ‘Array(value)`.
-
#validate!(value, options: {}, context: nil) ⇒ void
Validates the Array value.
Methods inherited from Base
cast!, deserialize, serialize, #serialize, validate!
Instance Method Details
permalink #deserialize(value) ⇒ ::Array
Deserializes the value into an array using ‘Array(value)`.
20 21 22 |
# File 'lib/castkit/types/collection.rb', line 20 def deserialize(value) Array(value) end |
permalink #validate!(value, options: {}, context: nil) ⇒ void
This method returns an undefined value.
Validates the Array value.
30 31 32 |
# File 'lib/castkit/types/collection.rb', line 30 def validate!(value, options: {}, context: nil) Castkit::Validators::CollectionValidator.call(value, options: , context: context) end |