Module: HasUniqueToken::ClassMethods
- Defined in:
- lib/has_unique_token.rb
Overview
Class methods
Instance Method Summary collapse
-
#token ⇒ Object
returns unique hex token.
-
#valid_token?(token) ⇒ Boolean
returns true if app exists for given token.
Instance Method Details
#token ⇒ Object
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
20 21 22 |
# File 'lib/has_unique_token.rb', line 20 def valid_token?(token) exists?(:token => token) end |