class ActiveSupport::Messages::Metadata

def wrap(message, expires_at: nil, expires_in: nil, purpose: nil)

def wrap(message, expires_at: nil, expires_in: nil, purpose: nil)
  if expires_at || expires_in || purpose
    JSON.encode new(encode(message), pick_expiry(expires_at, expires_in), purpose)
  else
    message
  end
end