Skip to content

Instantly share code, notes, and snippets.

@dpk
Forked from wycats/marshal_proc.rb
Created November 7, 2014 10:53
Show Gist options
  • Save dpk/57cb6aad6d843ff46eb3 to your computer and use it in GitHub Desktop.
Save dpk/57cb6aad6d843ff46eb3 to your computer and use it in GitHub Desktop.
module Rubinius
class CompiledCode
def _dump(depth)
Marshal.dump([@scope, Rubinius::ToolSets::Runtime::CompiledFile::Marshal.new.marshal(self)])
end
def self._load(string)
scope, dump = Marshal.load(string)
cm = Rubinius::ToolSets::Runtime::CompiledFile::Marshal.new.unmarshal(dump)
cm.scope = scope
cm
end
end
class VariableScope
def _dump(depth)
Marshal.dump([@method, @module, @parent, @self, nil, locals])
end
def self._load(string)
VariableScope.synthesize *Marshal.load(string)
end
end
class StaticScope
def marshal_dump
[@module, @current_module, @parent]
end
def marshal_load(array)
@module, @current_module, @parent = array
end
end
class BlockEnvironment
def marshal_dump
[@scope, @compiled_code]
end
def marshal_load(array)
scope, code = *array
under_context scope, code
#under_context *array
end
end
end
class Proc
def _dump(depth)
Marshal.dump(@block)
end
def self._load(string)
block = Marshal.load(string)
self.__from_block__(block)
end
end
@dpk
Copy link
Author

dpk commented Nov 7, 2014

TypeError: singleton class can't be dumped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment