Class: Type::ArrayOfSymptomsType

Inherits:
ActiveModel::Type::Value
  • Object
show all
Defined in:
lib/kb/type/array_of_symptoms_type.rb

Constant Summary collapse

SYMPTOM_KEYS =
KB::Symptom.attribute_types.keys.map(&:to_sym)

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/kb/type/array_of_symptoms_type.rb', line 5

def cast(value)
  (value || []).map do |v|
    next v if v.is_a? KB::Symptom

    KB::Symptom.new v.symbolize_keys.slice(*SYMPTOM_KEYS)
  end
end