Created
April 15, 2014 16:43
-
-
Save munshkr/10746556 to your computer and use it in GitHub Desktop.
Marshal for Sequel models (using #marshal_dump and #marshal_load)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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