jch/barn — pull request #15 by simeonwillbanks (2013-10-03 18:40:20+00:00)
Title: Simplify Usage

Fixes #10
Fixes #14

During this refactor, I referenced the [Getting Started Guide](https://github.com/jch/barn/blob/master/docs/getting_started.md) and the [build-merge.rb Gist](https://gist.github.com/jch/ee5213f6db7aae5a6dfe). The goal was simplifying/reducing code required to `define` and `build`.

* Since `Barn.define` blocks do not have piped lists, `instance_eval` the block
instead of calling the block. This allows us to change the context/receiver,
so `build` shorthand works even if `Helpers` have not been included
* Build chain requires `Barn::Builders::Hash` to exist and be last
* `Barn::Builders::Hash` conditionally mutates `object` when build options are a `Hash`
* When `object` is a `Hash`, merge build options
* When `object` is not a `Hash` (`ActiveRecord`, `OpenStruct`, etc), send build
options to `object`
* `Barn::Builders::ActiveRecord` conditionally instantiates inferred class
* To instantiate the class, a class must exist
* Do not instantiate class when `object` is already an instance of class
* Remove debugger

Since #13 isn't merge, here is how I ran the tests in Z shell. They pass!

```
$ rubies=(1.8.7-p358 ree-1.8.7-2011.03 1.9.2-p290 1.9.3-p429 2.0.0-p247)

$ for r in $rubies
do
rbenv local $r; bundle install; bundle exec ruby test/barn_test.rb; bundle exec ruby test/builder/activerecord_test.rb; bundle exec ruby test/builder/hash_test.rb;
done
```