Sha256: fd116dbf04927f392eed2a1ec6a6fdbae77492b9d4c14e6808deb76a5703b563

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 KB

Contents

module MessagePack
  class Unpacker
    # see ext for other methods

    # The semantic of duping an unpacker is just too weird.
    undef_method :dup
    undef_method :clone

    def register_type(type, klass = nil, method_name = nil, &block)
      if klass && method_name
        block = klass.method(method_name).to_proc
      elsif !block_given?
        raise ArgumentError, "register_type takes either 3 arguments or a block"
      end
      register_type_internal(type, klass, block)
    end

    def registered_types
      list = []

      registered_types_internal.each_pair do |type, ary|
        list << {type: type, class: ary[0], unpacker: ary[1]}
      end

      list.sort{|a, b| a[:type] <=> b[:type] }
    end

    def type_registered?(klass_or_type)
      case klass_or_type
      when Class
        klass = klass_or_type
        registered_types.any?{|entry| klass == entry[:class] }
      when Integer
        type = klass_or_type
        registered_types.any?{|entry| type == entry[:type] }
      else
        raise ArgumentError, "class or type id"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
msgpack-1.8.0-java lib/msgpack/unpacker.rb
msgpack-1.8.0 lib/msgpack/unpacker.rb
msgpack-1.7.5 lib/msgpack/unpacker.rb
msgpack-1.7.5-java lib/msgpack/unpacker.rb
msgpack-1.7.4-java lib/msgpack/unpacker.rb
msgpack-1.7.4 lib/msgpack/unpacker.rb
msgpack-1.7.3-java lib/msgpack/unpacker.rb
msgpack-1.7.3 lib/msgpack/unpacker.rb
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/unpacker.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/unpacker.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/unpacker.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/unpacker.rb
msgpack-1.7.2-java lib/msgpack/unpacker.rb
msgpack-1.7.2 lib/msgpack/unpacker.rb