Record class changes and replay them. This may not look particularly useful at first, but combined with the Syncro gem (github.com/maccman/syncro), you can easily implement Ruby class synchronisation between remote clients.
Example:
require "scriber"
class Test
class << self
def var
@var
end
def var=(v)
@var = v
end
def scribe_play(type, data)
case type
when :var=
self.var = data
end
end
end
end
Scriber.record(Test, :var=, 1)
Scriber.record(Test, :var=, 2)
Scriber.record(Test, :var=, 3)
Scriber.play
Test.var #=> 3
To persist Scriber recordings, setup SuperModel’s marshalling:
SuperModel::Marshal.path = “dump.db” SuperModel::Marshal.load
at_exit
SuperModel::Marshal.dump