<commit_before># Autodeps

TODO: Write a gem description

## Installation

Add this line to your application's Gemfile:

    gem 'autodeps'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install autodeps

## Usage

TODO: Write usage instructions here
two parts
1.ReactivePersistency
2.ReactiveData

ReactivePersistency is used in data storage layer, like you have an activerecord/mongomapper persistency layer,
when some properties you want to copy to other table(denormalization), and want to be automatically synced when
main table's property changes,
then just include Autodeps::Persistency and call depend_on  method:
like you have User table, and Laud table, where you copy user.name to Laud.user_name and Laud.dest_user_name
```
class Laud

  include MongoMapper::Document
  include Autodeps::Persistency #这里添加对Autodeps::Persistency 的依赖

  key :user_id, Integer, :required => true
  key :user_name, String
  depend_on "User", :value_mapping => {:name => :user_name} #默认可以省略 :key_mapping=> {:id=>:user_id}

  key :dest_user_id, Integer, :required => true
  key :dest_user_name, String
  depend_on "User", :key_mapping => {:id => :dest_user_id}, :value_mapping => {:name => :dest_user_name}
<commit_msg>update README to use English<commit_after># Autodeps

It's like an auto reactive data source, (like in meteor),
when you update one place's data, its change automatically propagate to some other place.
so the basic usage is two places
1.ReactiveData, where the value of dependent changes propagate to the depended on.
2.ReactivePersistency,it's the same idea, but in persisent layer,
normally many times you'll have denormalize data like you copy user's name to
User's message/comment/likes/lauds etc table to improve performance, but the unfortunate
effect is you need to remember to update all those places when your user name changes,
so basiclly it's a custom save inside many after_save hook, very manually and error prone.
the ReactivePersistency solves this problem.

## Installation

Add this line to your application's Gemfile:

    gem 'autodeps'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install autodeps

## Usage

TODO: Write usage instructions here
two parts
1.ReactivePersistency
2.ReactiveData

ReactivePersistency is used in data storage layer, like you have an activerecord/mongomapper persistency layer,
when some properties you want to copy to other table(denormalization), and want to be automatically synced when
main table's property changes,
then just include Autodeps::Persistency and call depend_on  method:
like you have User table, and Laud table, where you copy user.name to Laud.user_name and Laud.dest_user_name
```
class Laud

  include MongoMapper::Document
  include Autodeps::Persistency #adds dependency to Autodeps::Persistency

  key :user_id, Integer, :required => true
  key :user_name, String
  depend_on "User", :value_mapping => {:name => :user_name} #we can omit :key_mapping=> {:id=>:user_id}

  key :dest_user_id, Integer, :required => true
  key :dest_user_name, String
  depend_on "User", :key_mapping => {:id => :dest_user_id}, :value_mapping => {:name => :dest_user_name}

{'fraction_non_alphanumeric': 0.07506281407035176, 'fraction_numerical': 0.0018844221105527637, 'mean_word_length': 5.089866156787763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '3643749', 'n_tokens_mistral': 987, 'n_tokens_neox': 937, 'n_words': 389}