diff options
author | Chris Fallin <cfallin@c1f.net> | 2015-05-15 10:52:56 -0700 |
---|---|---|
committer | Chris Fallin <cfallin@c1f.net> | 2015-05-15 10:52:56 -0700 |
commit | a526605aec4358e948bde0a8ad63f5f1de6f2cb5 (patch) | |
tree | cc64517d7e1d38f72779f963294b36f78431d7a4 /ruby/lib/google/protobuf.rb | |
parent | 09e584b57aaa8e3e5c45162a8bdbc1d1864a8f5a (diff) | |
parent | d1b52a00e002fd7a4adbcdeafa0634de6088a88f (diff) | |
download | protobuf-a526605aec4358e948bde0a8ad63f5f1de6f2cb5.tar.gz protobuf-a526605aec4358e948bde0a8ad63f5f1de6f2cb5.tar.bz2 protobuf-a526605aec4358e948bde0a8ad63f5f1de6f2cb5.zip |
Merge pull request #338 from skippy/encode-decode-helpers
ruby: Encode decode cleanup and behavior normalization
Diffstat (limited to 'ruby/lib/google/protobuf.rb')
-rw-r--r-- | ruby/lib/google/protobuf.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ruby/lib/google/protobuf.rb b/ruby/lib/google/protobuf.rb index 72797245..99b17929 100644 --- a/ruby/lib/google/protobuf.rb +++ b/ruby/lib/google/protobuf.rb @@ -28,6 +28,9 @@ # (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 mixins before we hook them into the java & c code +require 'google/protobuf/message_exts' + if RUBY_PLATFORM == "java" require 'json' require 'google/protobuf_java' @@ -36,3 +39,25 @@ else 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 |