The expression is evaluated first so when nil || "espg"
is equivalent to when "espg"
1 - it will never match nil
.
To match either-or, separate the options with a comma:
case type
when nil, "espg" ..
when "esri" ..
Or, alternatively, perhaps normalize the value:
case (type || "espg")
when "espg" ..
when "esri" ..
Or use the other form that resembles an if-else:
case
when type.nil? || type == "espg" ..
when type == "esri" ..
Or some combination of everything :)
1 This is also the same reason why the example if
is suspect. It should probably be written like:
if type.nil? || type == "espg"