Skip to content

Commit 19858f6

Browse files
committed
add new ext register API
1 parent 7f46606 commit 19858f6

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

mrblib/msgpack.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module MessagePack
2+
def self.register_ext_type(type, klass, pack:, unpack:)
3+
pack = pack.to_proc if pack.respond_to?(:to_proc)
4+
raise ArgumentError unless pack.is_a?(Proc)
5+
unpack = unpack.to_proc if unpack.respond_to?(:to_proc)
6+
raise ArgumentError unless unpack.is_a?(Proc)
7+
8+
register_pack_type(type, klass, &pack)
9+
register_unpack_type(type, &unpack)
10+
11+
nil
12+
end
13+
end

0 commit comments

Comments
 (0)