Module: Marshal

Defined in:
lib/pa/ext.rb

Overview

add Pa support in Marshal

Class Method Summary collapse

Class Method Details

.dump(obj, *args) ⇒ String

add support with Pa

Marshal.dump(obj, Pa(path))
dump(con, [obj], limit=-1)

Parameters:

  • obj (String, Pa)

Returns:

  • (String)


24
25
26
27
28
29
30
31
32
# File 'lib/pa/ext.rb', line 24

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

.load(obj) ⇒ String

add support with Pa

Marshal.load(Pa(path))

Parameters:

  • obj (IO, String, Pa)

Returns:

  • (String)


13
# File 'lib/pa/ext.rb', line 13

def load(obj) original_load Pa===obj ? File.read(obj.p) : obj end

.original_dumpObject



15
# File 'lib/pa/ext.rb', line 15

alias :original_dump :dump

.original_loadObject



5
# File 'lib/pa/ext.rb', line 5

alias :original_load :load