Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for ActiveSupport::EncryptedFile#read [ci-skip] #45570

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions activesupport/lib/active_support/encrypted_file.rb
Expand Up @@ -49,6 +49,14 @@ def key
read_env_key || read_key_file || handle_missing_key
end

# Reads the file and returns the decrypted content.
#
# Raises:
# - MissingKeyError if the key is missing and +raise_if_missing_key+ is true.
# - MissingContentError if the encrypted file does not exist or otherwise
# if the key is missing.
# - ActiveSupport::MessageEncryptor::InvalidMessage if the content cannot be
# decrypted or verified.
def read
if !key.nil? && content_path.exist?
decrypt content_path.binread
Expand Down