<commit_before># Mongoid::Token - Short snappy tokens for Mongoid documents

[![Build Status](https://secure.travis-ci.org/thetron/mongoid_token.png)](http://travis-ci.org/thetron/mongoid_token)
[![Code Climate](https://codeclimate.com/github/thetron/mongoid_token.png)](https://codeclimate.com/github/thetron/mongoid_token)

This library is a quick and simple way to generate unique, random tokens
for your mongoid documents, in the cases where you can't, or don't want
to use slugs, or the default MongoDB ObjectIDs.

Mongoid::Token can help turn this:

    http://bestappever.com/video/4dcfbb3c6a4f1d4c4a000012

Into something more like this:

    http://bestappever.com/video/8tmQ9p


## Getting started

In your gemfile, add:

    gem 'mongoid_token', '~> 2.0.0'

Then update your bundle

    $ bundle update

In your Mongoid documents, just add `include Mongoid::Token` and the
`token` method will take care of all the setup, like so:

```ruby
class Person
  include Mongoid::Document
  include Mongoid::Token

  field :name

  token
end

```

And that's it! There's lots of configuration options too - which are all
listed [below](#configuration). By default, the `token` method will
create tokens 4 characters long, containing random alphanumeric characters.<commit_msg>Updated readme. Closes #60<commit_after># Mongoid::Token - Short snappy tokens for Mongoid documents

[![Build Status](https://secure.travis-ci.org/thetron/mongoid_token.png)](http://travis-ci.org/thetron/mongoid_token)
[![Code Climate](https://codeclimate.com/github/thetron/mongoid_token.png)](https://codeclimate.com/github/thetron/mongoid_token)

This library is a quick and simple way to generate unique, random tokens
for your mongoid documents, in the cases where you can't, or don't want
to use slugs, or the default MongoDB ObjectIDs.

Mongoid::Token can help turn this:

    http://bestappever.com/video/4dcfbb3c6a4f1d4c4a000012

Into something more like this:

    http://bestappever.com/video/8tmQ9p


## Getting started

In your gemfile, add:

    gem 'mongoid_token', '~> 2.0.0'

Then update your bundle

    $ bundle install

In your Mongoid documents, just add `include Mongoid::Token` and the
`token` method will take care of all the setup, like so:

```ruby
class Person
  include Mongoid::Document
  include Mongoid::Token

  field :name

  token
end

```

And that's it! There's lots of configuration options too - which are all
listed [below](#configuration). By default, the `token` method will
create tokens 4 characters long, containing random alphanumeric characters.
{'fraction_non_alphanumeric': 0.10038910505836576, 'fraction_numerical': 0.01556420233463035, 'mean_word_length': 4.650549450549451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1232087', 'n_tokens_mistral': 842, 'n_tokens_neox': 786, 'n_words': 270}