zlib icon indicating copy to clipboard operation
zlib copied to clipboard

Alias Zlib.deflate as Zlib.dump and Zlib.inflate as Zlib.load

Open casperisfine opened this issue 4 years ago • 4 comments

load and dump are a very popular naming convention for serializer and such, and defining them allows easy composition.

Example:

class CoderChain
  def initialize(*coders)
    @coders = coders.flatten
  end

  def dump(object)
    payload = object
    @coders.each { |c| payload = c.dump(payload) }
    payload
  end

  def load(payload)
    object = payload
    @coders.reverse_each { |c| object = c.load(object) }
    object
  end
end

CoderChain.new(Marshal, Zlib)
CoderChain.new(YAML, Snappy)

casperisfine avatar Mar 25 '21 08:03 casperisfine

I'm +1 to this change.

@akr Do you have any concerns this? I'm not sure what a background of zlib interface.

hsbt avatar Jan 05 '22 09:01 hsbt

?

casperisfine avatar Sep 12 '23 07:09 casperisfine

It's just spam.

hsbt avatar Sep 12 '23 07:09 hsbt

I banned Justman10000 from our organization.

hsbt avatar Sep 13 '23 05:09 hsbt