@@ -14,12 +14,16 @@ class Encryptor
14
14
# The compressor to use for compressing the payload.
15
15
attr_reader :compressor
16
16
17
- # === Options
17
+ # ==== Options
18
18
#
19
- # * <tt>:compress</tt> - Boolean indicating whether records should be compressed before encryption.
20
- # Defaults to +true+.
21
- # * <tt>:compressor</tt> - The compressor to use. It must respond to +deflate+ and +inflate+.
22
- # If not provided, will default to +ActiveRecord::Encryption.config.compressor+, which itself defaults to +Zlib+.
19
+ # [+:compress+]
20
+ # Boolean indicating whether records should be compressed before
21
+ # encryption. Defaults to +true+.
22
+ #
23
+ # [+:compressor+]
24
+ # The compressor to use. It must respond to +deflate+ and +inflate+.
25
+ # If not provided, will default to +ActiveRecord::Encryption.config.compressor+,
26
+ # which itself defaults to +Zlib+.
23
27
def initialize ( compress : true , compressor : nil )
24
28
@compress = compress
25
29
@compressor = compressor || ActiveRecord ::Encryption . config . compressor
@@ -31,17 +35,17 @@ def initialize(compress: true, compressor: nil)
31
35
#
32
36
# 1. Create a new ActiveRecord::Encryption::Message.
33
37
# 2. Compress and encrypt +clean_text+ as the message payload.
34
- # 3. Serialize it with +ActiveRecord::Encryption.message_serializer+ (+ActiveRecord::Encryption::SafeMarshal+
35
- # by default).
38
+ # 3. Serialize it with +ActiveRecord::Encryption.message_serializer+
39
+ # (+ActiveRecord::Encryption::SafeMarshal+ by default).
36
40
# 4. Encode the result with Base64.
37
41
#
38
- # === Options
42
+ # ==== Options
39
43
#
40
- # [:key_provider]
44
+ # [+ :key_provider+ ]
41
45
# Key provider to use for the encryption operation. It will default to
42
46
# +ActiveRecord::Encryption.key_provider+ when not provided.
43
47
#
44
- # [:cipher_options]
48
+ # [+ :cipher_options+ ]
45
49
# Cipher-specific options that will be passed to the Cipher configured in
46
50
# +ActiveRecord::Encryption.cipher+.
47
51
def encrypt ( clear_text , key_provider : default_key_provider , cipher_options : { } )
@@ -53,13 +57,13 @@ def encrypt(clear_text, key_provider: default_key_provider, cipher_options: {})
53
57
54
58
# Decrypts an +encrypted_text+ and returns the result as clean text.
55
59
#
56
- # === Options
60
+ # ==== Options
57
61
#
58
- # [:key_provider]
62
+ # [+ :key_provider+ ]
59
63
# Key provider to use for the encryption operation. It will default to
60
64
# +ActiveRecord::Encryption.key_provider+ when not provided.
61
65
#
62
- # [:cipher_options]
66
+ # [+ :cipher_options+ ]
63
67
# Cipher-specific options that will be passed to the Cipher configured in
64
68
# +ActiveRecord::Encryption.cipher+.
65
69
def decrypt ( encrypted_text , key_provider : default_key_provider , cipher_options : { } )
0 commit comments