Class: Keymail::Token

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/keymail/token.rb

Instance Method Summary collapse

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'app/models/keymail/token.rb', line 8

def expired?
  expires_at.past?
end

#generate_tokenObject



16
17
18
19
20
# File 'app/models/keymail/token.rb', line 16

def generate_token
  begin
    self.url_key = SecureRandom.urlsafe_base64
  end while Token.exists?(url_key: self.url_key)
end

#urlObject



12
13
14
# File 'app/models/keymail/token.rb', line 12

def url
  Rails.application.routes.url_helpers.keymail_link_target_url(url_key)
end