Sha256: 1d42cf2604e4bb147d069bd43681591cad43f1a262cf5759fa0db1bfcb328954

Contents?: true

Size: 418 Bytes

Versions: 10

Compression:

Stored size: 418 Bytes

Contents

module Notee
  class Token < ActiveRecord::Base

    # callbacks
    before_create :generate_access_token
    before_create :set_expires_at

    private

    def generate_access_token
      begin
        self.access_token = SecureRandom.hex
      end while self.class.exists?(access_token: access_token)
    end

    def set_expires_at
      self.expires_at = Time.current + (60 * 60 * 24 * 7) #7日
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
notee-0.3.7 app/models/notee/token.rb
notee-0.3.6 app/models/notee/token.rb
notee-0.3.5 app/models/notee/token.rb
notee-0.3.4.1 app/models/notee/token.rb
notee-0.3.4 app/models/notee/token.rb
notee-0.3.3 app/models/notee/token.rb
notee-0.3.2 app/models/notee/token.rb
notee-0.3.1 app/models/notee/token.rb
notee-0.3.0 app/models/notee/token.rb
notee-0.2.9 app/models/notee/token.rb