Sha256: e8ea3b2b8f1563bc8d548832c4d370b3c5fee1328e1872cfbea98a320c3759d3

Contents?: true

Size: 731 Bytes

Versions: 10

Compression:

Stored size: 731 Bytes

Contents

# add Pa support in Marshal
module Marshal 
  class <<self

    alias :original_load :load

    # add support with Pa
    #
    #   Marshal.load(Pa(path))
    #
    # @param [IO,String,Pa] obj
    # @return [String]
    def load(obj) original_load Pa===obj ? File.read(obj.p) : obj end

    alias :original_dump :dump

    # add support with Pa
    #
    #   Marshal.dump(obj, Pa(path))
    #   dump(con, [obj], limit=-1)
    #
    # @param [String,Pa] obj
    # @return [String]
    def dump(obj, *args)
      case args[0]
      when String, Pa
        path = String===args[0] ? args[0] : args[0].p
        open(path, "wb"){|f| f.write(original_dump(con))}
      else
        original_dump con, *args
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pa-1.4.0 lib/pa/ext.rb
pa-1.3.3 lib/pa/ext.rb
pa-1.3.2 lib/pa/ext.rb
pa-1.3.1 lib/pa/ext.rb
pa-1.3.0 lib/pa/ext.rb
pa-1.2.3 lib/pa/ext.rb
pa-1.2.2 lib/pa/ext.rb
pa-1.2.1 lib/pa/ext.rb
pa-1.2.0 lib/pa/ext.rb
pa-1.1.4 lib/pa/ext.rb