3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/helpers/anchor/fetch_or_fallback_helper.rb', line 3
def fetch_or_fallback(allowed_values, given_value, fallback = nil)
if allowed_values.include?(given_value)
given_value
else
unless Rails.env.production?
raise ArgumentError, <<~MSG
fetch_or_fallback was called with an invalid value.
Expected one of: #{allowed_values.inspect}
Got: #{given_value.inspect}
This will not raise in production, but will instead fallback to: #{fallback.inspect}
MSG
end
fallback
end
end
|