diff options
Diffstat (limited to 'ruby/lib/google/protobuf.rb')
-rw-r--r-- | ruby/lib/google/protobuf.rb | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/ruby/lib/google/protobuf.rb b/ruby/lib/google/protobuf.rb index 74053332..f0eb6268 100644 --- a/ruby/lib/google/protobuf.rb +++ b/ruby/lib/google/protobuf.rb @@ -28,4 +28,45 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'google/protobuf_c' +# require mixins before we hook them into the java & c code +require 'google/protobuf/message_exts' + +# We define these before requiring the platform-specific modules. +# That way the module init can grab references to these. +module Google + module Protobuf + class Error < StandardError; end + class ParseError < Error; end + end +end + +if RUBY_PLATFORM == "java" + require 'json' + require 'google/protobuf_java' +else + require 'google/protobuf_c' +end + +require 'google/protobuf/repeated_field' + +module Google + module Protobuf + + def self.encode(msg) + msg.to_proto + end + + def self.encode_json(msg) + msg.to_json + end + + def self.decode(klass, proto) + klass.decode(proto) + end + + def self.decode_json(klass, json) + klass.decode_json(json) + end + + end +end |