Sha256: 8104d237477830540e80ed7251934467cc14352c4093a9171eb79233a5fd08c5

Contents?: true

Size: 522 Bytes

Versions: 2

Compression:

Stored size: 522 Bytes

Contents

module TokenAction
  module TokenGenerator
    extend ActiveSupport::Concern

    module ClassMethods
      # Returns a new alphanumeric token.
      #
      # @param [String,Symbol] column an attribute
      # @return [String] a random alphanumeric string
      # @see Devise::Models::Authenticatable::ClassMethods
      def generate_token(column)
        loop do
          token = TokenAction.friendly_token
          break token unless to_adapter.find_first({ column => token })
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
token_action-0.0.2 lib/token_action/concerns/token_generator.rb
token_action-0.0.1 lib/token_action/mixins/token_generator.rb