mongodb/mongo-ruby-driver — pull request #212 by TylerBrock (2013-06-17 13:06:29+00:00)
Title: RUBY-595

This is the initial commit for implementation of the modeled MongoDB wire protocol.

### The Wire Protocol
Provides an abstract base class named `Message` that all messages will extend.

I chose to use a class instead of a module because for modeling `Message` because I believe the relationship between `Message` and messages is best defined as a "is-a" relationship instead of a "behaves-like" relationship and has the benefit of clearly delineating methods which are public (`#serialize` and `#deserialize`) from those which are protected and called only by the subclasses of Message (`#field`). In addition, the documentation looks cleaner and we may want to keep Message class level state in the future.

### The DSL
The basic functionality included in the Message class allows for messages to be defined through the use of field declarations. Fields are denoted, in order, by name and type (implying a particular serialization strategy) through a simple DSL:

```ruby
field :length, Int32
field :namespace, CString
field :document, Document
```

### Serialization and Deserialization
The serialization strategies contained in the Serializers module each have their own submodule in order to quickly and directly invoke the correct strategy for a field.

### Tests
The tests only excercise the public interfaces provided and are designed to prevent brittleness if based on implementation.