demarches-normaliennes/app/models/logic/and.rb

19 lines
455 B
Ruby
Raw Normal View History

2022-06-09 14:00:18 +02:00
class Logic::And < Logic::NAryOperator
attr_reader :operands
def operator_name = 'Et'
def compute(champs = [])
@operands.map { |operand| operand.compute(champs) }.all?
end
def computable?(champs = [])
return true if sources.blank?
champs.filter { _1.stable_id.in?(sources) && _1.visible? }
.all? { _1.value.present? }
end
2022-09-26 21:21:55 +02:00
def to_s(type_de_champs) = "(#{@operands.map { |o| o.to_s(type_de_champs) }.join(' && ')})"
2022-06-09 14:00:18 +02:00
end