estately/rets — pull request #78 by hfaulds (2014-09-24 14:29:04+00:00)
Title: Move metadata fetching to Client from Rets::Metadata::Root

Currently there is a weird control flow here where you pass a block into `Rets::Metadata::Root` which it then calls in its constructor.

Simpler to understand and easier from a testing point of view is to run the block outside of the Root node and just pass in the results.

This makes `Rets::Metadata::Root` just responsible for the presentation of information.

This also allows for easy caching of the raw metadata outside of the rets gem through `Rets::Metadata::Root#marshall_dump`.

```
client = Rets::Client.new(:login_url => "http://example.com")
set_cache(client.metadata.marshall_dump)
...
cached_metadata = Rets::Metadata::Root.new(get_cache)
client = Rets::Client.new(:login_url => "http://example.com", :metadata => cached_metadata)
```

Currently you have to either persist the entire `Rets::Metadata::Root` object (including the `tree` and `metadata_types` instance vars which may or may not have been created).
Or create an empty `Rets::Metadata::Root` and then manually set the sources.