<commit_before>active_hash_fields
======

*An ActiveRecord extension to add serialized hash fields that act like objects*

Usecase
------------------------
A `User` should be able to set various notification options for various events. For example, he may want to receive an email notification when someone leaves a comment for his blog post, but not when someone replies with a comment to his comment.

This can usually be solved by either creating an additional associated model like `NotificationSettings` or by creating numerous fields in the `User` model itself. Not quite efficient either way.

Usage
------------------------

Here's the solution:

    class User < ActiveRecord::Base

      active_hash_fields :notitications,<commit_msg>Updating README with an instruction about migrating the model and adding a field for a serialized hash<commit_after>active_hash_fields
======

*An ActiveRecord extension to add serialized hash fields that act like objects*

Usecase
------------------------
A `User` should be able to set various notification options for various events. For example, he may want to receive an email notification when someone leaves a comment for his blog post, but not when someone replies with a comment to his comment.

This can usually be solved by either creating an additional associated model like `NotificationSettings` or by creating numerous fields in the `User` model itself. Not quite efficient either way.

Usage
------------------------

Here's the solution. First add a field to store all nested fields as a serialized hash:

    class AddNotificationsToUsers < ActiveRecord::Migration
      def change
        add_column :users, :notifications, :text
      end
    end
    
Then define nested fields in your model:

    class User < ActiveRecord::Base

      active_hash_fields :notitications,
{'fraction_non_alphanumeric': 0.09046321525885559, 'fraction_numerical': 0.0, 'mean_word_length': 3.3923444976076556, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1250827', 'n_tokens_mistral': 411, 'n_tokens_neox': 401, 'n_words': 236}