Skip to content

Instantly share code, notes, and snippets.

@munshkr
Created April 15, 2014 16:43
Show Gist options
  • Save munshkr/10746556 to your computer and use it in GitHub Desktop.
Save munshkr/10746556 to your computer and use it in GitHub Desktop.
Marshal for Sequel models (using #marshal_dump and #marshal_load)
module Sequel
class Model
module InstanceMethods
def marshal_dump
marshallable!
Hash[instance_variables.map { |iv| [iv, instance_variable_get(iv)] }]
end
def marshal_load(variables)
variables.each { |k, v| instance_variable_set(k, v) }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment