localshred/protobuf — pull request #174 by localshred (2014-02-18 22:20:53+00:00)
Title: Pass in the defined type when building a field

When the field class is enum or message we need to pass the actual class as
the type, not EnumField or MessageField (or symbol).

This is because for messages and enums, we expect to be dealing with a
message/enum instance instead of the field instance.

Example

```ruby
class Foo < ::Protobuf::Message
# expands to Protobuf::Field::StringField.new(Foo, :optional, Protobuf::FieldString, :name, 1, {})
optional :string, :name, 1
end

# Notice the difference between what we're initializing and
# what we're passing as the type (Foo in this case, not MessageField)
class Bar < Protobuf::Message
# expands to Protobuf::Field::MessageField.new(Bar, :optional, Foo, :foo, 1, {})
optional Foo, :foo, 1
end
```