Skip to content

Instantly share code, notes, and snippets.

@munshkr
Last active August 29, 2015 13:59
Show Gist options
  • Save munshkr/10740867 to your computer and use it in GitHub Desktop.
Save munshkr/10740867 to your computer and use it in GitHub Desktop.
Marshal for Sequel models
module Sequel
class Model
module InstanceMethods
def _dump(level)
Marshal.dump(values: values, new: new?, modified: modified?)
end
end
module ClassMethods
def _load(args)
attrs = Marshal.load(args)
inst = new(attrs[:values])
inst.instance_variable_set("@new", attrs[:new])
inst.instance_variable_set("@modified", attrs[:modified])
inst
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment