Method: Moped::Protocol::Message::ClassMethods#finalize
- Defined in:
- lib/moped/protocol/message.rb
#finalize ⇒ Object
Declares the message class as complete, and defines its serialization method from the declared fields.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/moped/protocol/message.rb', line 276 def finalize class_eval <<-EOS, __FILE__, __LINE__ + 1 def serialize(buffer = "") start = buffer.bytesize #{fields.map { |f| "serialize_#{f}(buffer)" }.join("\n")} self.length = buffer.bytesize - start buffer[start, 4] = serialize_length "" buffer end alias to_s serialize EOS end |