<commit_before># FlattenRecord

An ActiveRecord plugin that denormalizes your existing ActiveRecord models. 

It includes generation of migration, observing the save/destory on target model and changes the records accordingly. It provides an easier way to create denormalized models to be used in reporting.

## Example
    class DenormalizedOrderLineItem < ActiveRecord::Base
    	include FlattenRecord::Denormalize

    	denormalize :order do |order|
      		order.denormalize :customer
      		order.denormalize :line_items do |line_item|
        		line_item.denormalize(:redeem, as: :discount){|d| d.denormalize(:coupon) }
      		order.save :order_sum, :decimal
    	end

    	private
    	def _save_order_sum(order)
      		order_sum = order.line_items.inject(0){|sum, i| sum += i.total }
    	end
  	end

## Changes

_still in alpha_  


## License  
see the MIT-LICENSE file.<commit_msg>corrected example and updated milestones<commit_after># FlattenRecord

An ActiveRecord plugin that denormalizes your existing ActiveRecord models. 

It includes generation of migration, observing the save/destory on target model and changes the records accordingly. It provides an easier way to create denormalized models to be used in reporting.

## Example
    class DenormalizedOrderLineItem < ActiveRecord::Base
    	include FlattenRecord::Denormalize

    	denormalize :order do |order|
      		order.denormalize :customer
      		order.denormalize :line_items do |line_item|
        		line_item.denormalize(:redeem, as: :discount){|d| d.denormalize(:coupon) }
      		order.save :order_sum, :decimal
    	end

    	private
    	def _get_order_sum(order)
      		order.line_items.collect(&:total).inject(:+)
    	end
  	end

## Changes

#####v1   
_still in development_  
- denormalize fields and nested fields √  
- generate migration from denormalized model √   
- observe model changes and update denormalized model √  
- ...

## License  
see the MIT-LICENSE.
{'fraction_non_alphanumeric': 0.07281059063136457, 'fraction_numerical': 0.0010183299389002036, 'mean_word_length': 3.5172413793103448, 'pattern_counts': {'":': 0, '<': 5, '<?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': '693948', 'n_tokens_mistral': 599, 'n_tokens_neox': 582, 'n_words': 187}