method

prepend

rails latest stable - Class: ActiveSupport::MessageVerifiers

Method not available on this version

This method is only available on newer versions. The first available version (v8.1.1) is shown here.

prepend
public

Just like #rotate, but prepends the given options or block to the list of option sets.

This can be useful when you have an already-configured MessageVerifiers instance, but you want to override the way messages are signed.

module ThirdParty
  VERIFIERS = ActiveSupport::MessageVerifiers.new { ... }.
    rotate(serializer: Marshal, url_safe: true).
    rotate(serializer: Marshal, url_safe: false)
end

ThirdParty.VERIFIERS.prepend(serializer: JSON, url_safe: true)

# Uses `serializer: JSON, url_safe: true`.
# Falls back to `serializer: Marshal, url_safe: true` or
# `serializer: Marshal, url_safe: false`.
ThirdParty.VERIFIERS[:foo]