1# Protocol Buffers - Google's data interchange format 2# Copyright 2008 Google Inc. All rights reserved. 3# 4# Use of this source code is governed by a BSD-style 5# license that can be found in the LICENSE file or at 6# https://developers.google.com/open-source/licenses/bsd 7 8module Google 9 module Protobuf 10 module MessageExts 11 12 #this is only called in jruby; mri loades the ClassMethods differently 13 def self.included(klass) 14 klass.extend(ClassMethods) 15 end 16 17 module ClassMethods 18 end 19 20 def to_json(options = {}) 21 self.class.encode_json(self, options) 22 end 23 24 def to_proto(options = {}) 25 self.class.encode(self, options) 26 end 27 28 end 29 class AbstractMessage 30 include MessageExts 31 extend MessageExts::ClassMethods 32 end 33 private_constant :AbstractMessage 34 end 35end 36