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



1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
# File 'lib/brick.rb', line 1833

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