redding/mr — pull request #199 by jcredding (2014-04-03 16:38:22+00:00)
Title: Fix read model factories applying args

This fixes a couple issues with read models applying args.
Firstly, read models would allow configuring `default_args` but
would never use them. Secondly, read models would not allow
procs for arg values like the other factories do. This fixes the
issues by making read model factories use the applying args
logic fully and also making it use configured default args.
Previously, it would only deep merge hashes which would is why it
didn't allow procs.

This involved making a factory `Data` class that has the args
applied to it and is passed to the read model. The class is a
hybrid between an open struct (allows dynamic writers) and a hash
(access the values through `[]`). This is a direction I eventually
wanted to go with the read model factory but I was planning on
doing it when I redid the applying args logic, because I'm not
very satisfied with where its at. I still don't love this
implementation but it gets the feature working correctly.

With this change it's not necessary to allow passing a hash to a
read model, which is why it requires the `[]` method. In the
future I will also probably look into changing this requirement.

I did some manual benchmarking of this change in a large apps test
suite and it didn't have any significant effect. Model, record and
read model factories aren't setup in MR's benchmarking yet.