0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

FIX: cast both key and value as boolean if operator is `is:[true|false]`

Dieser Commit ist enthalten in:
angusmcleod 2021-10-20 20:48:38 +08:00
Ursprung 774cf70efc
Commit 805e934fdf

Datei anzeigen

@ -143,7 +143,7 @@ class CustomWizard::Mapper
if value == "present" if value == "present"
result = key.public_send(operator) result = key.public_send(operator)
elsif ["true", "false"].include?(value) elsif ["true", "false"].include?(value)
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value)) result = bool(key).public_send(operator, bool(value))
end end
elsif [key, value, operator].all? { |i| !i.nil? } elsif [key, value, operator].all? { |i| !i.nil? }
result = key.public_send(operator, value) result = key.public_send(operator, value)
@ -265,4 +265,8 @@ class CustomWizard::Mapper
result = data[k] result = data[k]
keys.empty? ? result : self.recurse(result, keys) keys.empty? ? result : self.recurse(result, keys)
end end
def bool(value)
ActiveRecord::Type::Boolean.new.cast(value)
end
end end