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



2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
# File 'lib/brick.rb', line 2100

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