Module: HasUniqueToken::ClassMethods

Defined in:
lib/has_unique_token.rb

Overview

Class methods

Instance Method Summary collapse

Instance Method Details

#tokenObject

returns unique hex token



14
15
16
17
# File 'lib/has_unique_token.rb', line 14

def token
  generated = ActiveSupport::SecureRandom.hex.downcase 
  exists?(:token => generated) ? self.token : generated
end

#valid_token?(token) ⇒ Boolean

returns true if app exists for given token

Returns:

  • (Boolean)


20
21
22
# File 'lib/has_unique_token.rb', line 20

def valid_token?(token)
  exists?(:token => token)
end