Created
July 12, 2010 21:52
-
-
Save solnic/473122 to your computer and use it in GitHub Desktop.
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
# This is just a dummy example of a property with a "fallback" mechanism | |
# that an adapter should use if it doesn't know how to natively persist | |
# a property value. | |
# | |
# In this case we're dealing with an array that some datastores can persist | |
# and others need to call dump before persisting and load after retrieving | |
# a property value. | |
module DataMapper | |
class Property | |
class Array < Object | |
primitive ::Array | |
fallback_to ::String | |
def dump(value) | |
value.join(',') | |
end | |
def load(value) | |
value.split(',') | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment