Sha256: 2ef979708b1918d51594b4e0558ad0009a099eaa36b7dd8fe01af5c50f6f0e5b

Contents?: true

Size: 1013 Bytes

Versions: 14

Compression:

Stored size: 1013 Bytes

Contents

module MessagePack
  class Packer
    # see ext for other methods

    # The semantic of duping a packer is just too weird.
    undef_method :dup
    undef_method :clone

    def register_type(type, klass, method_name = nil, &block)
      raise ArgumentError, "expected Module/Class got: #{klass.inspect}" unless klass.is_a?(Module)
      register_type_internal(type, klass, block || method_name.to_proc)
    end

    def registered_types
      list = []

      registered_types_internal.each_pair do |klass, ary|
        list << {type: ary[0], class: klass, packer: 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/packer.rb
msgpack-1.8.0 lib/msgpack/packer.rb
msgpack-1.7.5 lib/msgpack/packer.rb
msgpack-1.7.5-java lib/msgpack/packer.rb
msgpack-1.7.4-java lib/msgpack/packer.rb
msgpack-1.7.4 lib/msgpack/packer.rb
msgpack-1.7.3-java lib/msgpack/packer.rb
msgpack-1.7.3 lib/msgpack/packer.rb
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/packer.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/packer.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/packer.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/msgpack-1.7.2/lib/msgpack/packer.rb
msgpack-1.7.2-java lib/msgpack/packer.rb
msgpack-1.7.2 lib/msgpack/packer.rb