Avoid polluting namespace

This commit is contained in:
Sam Oliver
2021-09-17 13:12:47 +02:00
parent a58ec254f6
commit f6d316bf1e
7 changed files with 37 additions and 31 deletions

View File

@@ -0,0 +1,11 @@
module ObjectPersistence
refine Object do
def save_to_file(filename)
File.open(filename, "w+") { |f| f << Marshal.dump(self) }
end
def self.load_from_file(filename)
Marshal.load(File.read(filename))
end
end
end