Class: Chamber::Filters::EncryptionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/chamber/filters/encryption_filter.rb

Constant Summary collapse

BASE64_STRING_PATTERN =
%r{\A[A-Za-z0-9+/]{342}==\z}.freeze
BASE64_SUBSTRING_PATTERN =
%r{[A-Za-z0-9+/#]*={0,2}}.freeze
LARGE_DATA_STRING_PATTERN =
/
  \A
  (#{BASE64_SUBSTRING_PATTERN})
  \#
  (#{BASE64_SUBSTRING_PATTERN})
  \#
  (#{BASE64_SUBSTRING_PATTERN})
  \z
/x.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, secure_key_prefix:, encryption_keys: {}, **_args) ⇒ EncryptionFilter

Returns a new instance of EncryptionFilter.



35
36
37
38
39
# File 'lib/chamber/filters/encryption_filter.rb', line 35

def initialize(data:, secure_key_prefix:, encryption_keys: {}, **_args)
  self.encryption_keys  = (encryption_keys || {}).transform_keys(&:to_s)
  self.data             = data.deep_dup
  self.secure_key_token = /\A#{Regexp.escape(secure_key_prefix)}/
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



27
28
29
# File 'lib/chamber/filters/encryption_filter.rb', line 27

def data
  @data
end

#encryption_keysObject

Returns the value of attribute encryption_keys.



29
30
31
# File 'lib/chamber/filters/encryption_filter.rb', line 29

def encryption_keys
  @encryption_keys
end

#secure_key_tokenObject

Returns the value of attribute secure_key_token.



27
28
29
# File 'lib/chamber/filters/encryption_filter.rb', line 27

def secure_key_token
  @secure_key_token
end

Class Method Details

.execute(**args) ⇒ Object



31
32
33
# File 'lib/chamber/filters/encryption_filter.rb', line 31

def self.execute(**args)
  new(**args).__send__(:execute)
end