fetch_or_fallback

in app/lib/primer/fetch_or_fallback_helper.rb [27:49]


    def fetch_or_fallback(allowed_values, given_value, fallback = nil, deprecated_values: nil)
      if allowed_values.include?(given_value)
        given_value
      elsif deprecated_values&.include?(given_value)
        ActiveSupport::Deprecation.warn("#{given_value} is deprecated and will be removed in a future version.") unless Rails.env.production? || silence_deprecations?

        given_value
      else
        if fallback_raises && ENV["RAILS_ENV"] != "production" && ENV["STORYBOOK"] != "true"
          raise InvalidValueError, <<~MSG
            fetch_or_fallback was called with an invalid value.

            Expected one of: 
            Got: 

            This will not raise in production, but will instead fallback to: 
          MSG
        end

        fallback
      end
    end