1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def save!(file_location: "test", aoh: nil) self.class.save(file_location: file_location, aoh: self) end def self.save!(aoh: AOH.new(), file_location: nil) #save no matter what raise "file_location not specified or is nil (file_location: #{file_location.inspect})" if !file_location File.open( file_location , 'w' ) do |file_handle| Marshal.dump(aoh, file_handle) end end |
self.class.save calls the main AOH class’s save method, so it’s only defined once in my code. Just some quick notes to remember for later as I create a tiny little wiki with a single database file.