Class: TypedEAV::Field::TextArray
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- ApplicationRecord
- Base
- TypedEAV::Field::TextArray
- Defined in:
- app/models/typed_eav/field/text_array.rb
Constant Summary
Constants inherited from Base
Constants included from TypedStorage
TypedEAV::Field::TypedStorage::DEFAULT_OPERATORS_BY_COLUMN, TypedEAV::Field::TypedStorage::FALLBACK_OPERATORS
Instance Method Summary collapse
Methods inherited from Base
#allowed_option_values, #backfill_default!, #clear_option_cache!, #default_value, #default_value=, export_schema, #field_type_name, import_schema, #insert_at, #move_higher, #move_lower, #move_to_bottom, #move_to_top, #optionable?
Methods included from TypedStorage
#after_snapshot, #apply_default, #before_snapshot, #read_value, #value_changed?, #write_value
Instance Method Details
#array_field? ⇒ Boolean
14 |
# File 'app/models/typed_eav/field/text_array.rb', line 14 def array_field? = true |
#cast(raw) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/typed_eav/field/text_array.rb', line 16 def cast(raw) return [nil, false] if raw.nil? # Drop nil/blank/whitespace-only elements so required-check and size # validation compare against real content rather than HTML form stubs # (e.g. an empty row in a dynamic list posts as "" or " "). elements = Array(raw).filter_map do |v| next nil if v.nil? s = v.to_s s.strip.empty? ? nil : s end [elements.presence, false] end |
#validate_typed_value(record, val) ⇒ Object
31 32 33 |
# File 'app/models/typed_eav/field/text_array.rb', line 31 def validate_typed_value(record, val) validate_array_size(record, val) end |