Class: Types::CompactedArrayType
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- Types::CompactedArrayType
- Defined in:
- app/lib/types/compacted_array_type.rb
Overview
ActiveModel::Type replacement for Virtus::CompactedArray.
Accepts any value, flattens it into an array, then removes blank entries.
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
8 9 10 |
# File 'app/lib/types/compacted_array_type.rb', line 8 def cast(value) [(value.presence || [])].flatten.map(&:presence).compact end |
#changed_in_place?(raw_old, new_val) ⇒ Boolean
12 13 14 |
# File 'app/lib/types/compacted_array_type.rb', line 12 def changed_in_place?(raw_old, new_val) cast(raw_old) != cast(new_val) end |
#type ⇒ Object
6 |
# File 'app/lib/types/compacted_array_type.rb', line 6 def type = :compacted_array |