Sha256: 9c89be9c08ce4e323bdb084859c836f989331fc7e8f638039e19b78ac4b5625b

Contents?: true

Size: 584 Bytes

Versions: 5

Compression:

Stored size: 584 Bytes

Contents

class Symbol
  # to_msgpack_ext is supposed to return a binary string.
  # The canonical way to do it for symbols would be:
  #  [to_s].pack('A*')
  # However in this instance we can take a shortcut
  if method_defined?(:name)
    alias_method :to_msgpack_ext, :name
  else
    alias_method :to_msgpack_ext, :to_s
  end

  def self.from_msgpack_ext(data)
    # from_msgpack_ext is supposed to parse a binary string.
    # The canonical way to do it for symbols would be:
    #  data.unpack1('A*').to_sym
    # However in this instance we can take a shortcut
    data.to_sym
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
msgpack-1.4.4-java lib/msgpack/symbol.rb
msgpack-1.4.4 lib/msgpack/symbol.rb
msgpack-1.4.4.pre1-java lib/msgpack/symbol.rb
msgpack-1.4.3 lib/msgpack/symbol.rb
msgpack-1.4.3-java lib/msgpack/symbol.rb