patriciomacadden/miniconfig — pull request #3 by F-3r (2013-11-26 21:52:29+00:00)
Title: Add iteration capabilities to Config

I needed to iterate over every setting under a key in my miniconfig,
so I thought it could be usefull to have an #each method.

I love the fact that each `Config` instance is just a plain ruby object with instances variables and reader attributes (beatyful simplicity!).

The problem I faced was that it looked kind of dirty iterating over instance variables names and values to do it. So in order to implement `#each` I needed to change some of the internals of the Config, loosing perhaps such sense simplicity. On the other hand, the code became a little bit clearer (but, given the amuont of code, this can be totally subjective)

The changes are:
* In order to be able to visit each setting as a key-value pair, was
needed to retain the original hash in instance variable

* Accessor methods that are dinamically generated now uses such hash
instead of instance variables

The `Config#build` interface/implementation changed in accordance:
* It was receiving an unused 'object' parameter

* Original hash was passed as a parameter also, now it's accessed as
an instance variable.

* removed an ` if hash.is_a? Hash` from #build. I think it nothing but a
hash should be allowed to come from a config file (am I missing something here?)

Tell me what you think about it!