instance method prepend

Ruby on Rails 8.1.2

Since v8.1.2

Signature

prepend(**options)
prepend(&block)

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 MessageEncryptors instance, but you want to override the way messages are encrypted.

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

ThirdParty.ENCRYPTORS.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.ENCRYPTORS[:foo]
Source
# File activesupport/lib/active_support/message_encryptors.rb, line 126
    

Defined in activesupport/lib/active_support/message_encryptors.rb line 126 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::MessageEncryptors

Type at least 2 characters to search.

↑↓ navigate · open · esc close