Class: ActiveSupport::MessageEncryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/brick.rb

Instance Method Summary collapse

Instance Method Details

#encrypt_and_sign(value, *args, expires_at: nil, expires_in: nil, purpose: nil) ⇒ Object



1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
# File 'lib/brick.rb', line 1926

def encrypt_and_sign(value, *args, expires_at: nil, expires_in: nil, purpose: nil)
  encrypted = if method(:_encrypt).arity == 1
                _encrypt(value) # Rails <= 5.1
              else
                if args.last.is_a?(Hash)
                  expires_at ||= args.last[:expires_at]
                  expires_in ||= args.last[:expires_in]
                  purpose ||= args.last[:purpose]
                end
                _encrypt(value, expires_at: expires_at, expires_in: expires_in, purpose: purpose)
              end
  verifier.generate(encrypted)
end