<commit_before>Mongoid::Denormalize
====================

Helper module for denormalizing association attributes in Mongoid models. Why denormalize? Read *[A Note on Denormalization](http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails#MongoDBDataModelingandRails-ANoteonDenormalization)*.

Extracted from [coookin'](http://coookin.com), where it is used in production.


Installation
------------

Add the gem to your Bundler `Gemfile`:

    gem 'mongoid_denormalize'

Or install with RubyGems:

    $ gem install mongoid_denormalize


Usage
-----

In your model:

    # Include the helper method
    include Mongoid::Denormalize
    
    # Define your denormalized fields
    denormalize :name, :email, :from => :user



Example
-------

    def User
      include Mongoid::Document
      include Mongoid::Denormalize

      references_many :comments

      field :name
      field :email
      
      denormalize :name, :email, :to => :comments
    end
    
    def Comment
      include Mongoid::Document
      include Mongoid::Denormalize<commit_msg>fixed a bug in README<commit_after>Mongoid::Denormalize
====================

Helper module for denormalizing association attributes in Mongoid models. Why denormalize? Read *[A Note on Denormalization](http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails#MongoDBDataModelingandRails-ANoteonDenormalization)*.

Extracted from [coookin'](http://coookin.com), where it is used in production.


Installation
------------

Add the gem to your Bundler `Gemfile`:

    gem 'mongoid_denormalize'

Or install with RubyGems:

    $ gem install mongoid_denormalize


Usage
-----

In your model:

    # Include the helper method
    include Mongoid::Denormalize
    
    # Define your denormalized fields
    denormalize :name, :email, :from => :user



Example
-------

    class User
      include Mongoid::Document
      include Mongoid::Denormalize

      references_many :comments

      field :name
      field :email
      
      denormalize :name, :email, :to => :comments
    end
    
    class Comment
      include Mongoid::Document
      include Mongoid::Denormalize
{'fraction_non_alphanumeric': 0.11338289962825279, 'fraction_numerical': 0.0, 'mean_word_length': 3.2298624754420433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3124246', 'n_tokens_mistral': 652, 'n_tokens_neox': 623, 'n_words': 177}