Class: TypedEAV::Field::Select
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- ApplicationRecord
- Base
- TypedEAV::Field::Select
- Includes:
- Optionable
- Defined in:
- app/models/typed_eav/field/select.rb
Overview
Single-choice option-set field. Stores the chosen value in
string_value. Inherits optionable? = true, the public-facing
sorted allowed_values helper, and the protected
validate_option_inclusion helper from Field::Optionable. Stays a
direct child of Field::Base — Optionable is a concern (mixin), not
an intermediate STI class, because Select and MultiSelect don't
share a value_column.
Constant Summary
Constants inherited from Base
Constants included from TypedStorage
TypedStorage::DEFAULT_OPERATORS_BY_COLUMN, TypedStorage::FALLBACK_OPERATORS
Instance Method Summary collapse
Methods included from Optionable
Methods inherited from Base
#allowed_option_values, #array_field?, #backfill_default!, #clear_option_cache!, #default_value, #default_value=, #display_name, 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
#cast(raw) ⇒ Object
18 19 20 |
# File 'app/models/typed_eav/field/select.rb', line 18 def cast(raw) [raw&.to_s, false] end |
#validate_typed_value(record, val) ⇒ Object
22 23 24 |
# File 'app/models/typed_eav/field/select.rb', line 22 def validate_typed_value(record, val) validate_option_inclusion(record, val) end |