Class: Type::ArrayOfConditionsType

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

Constant Summary collapse

CONDITION_KEYS =
KB::Condition.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_conditions_type.rb', line 5

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

    KB::Condition.new v.symbolize_keys.slice(*CONDITION_KEYS)
  end
end