Skip to content

Instantly share code, notes, and snippets.

@solnic
Created July 12, 2010 21:52
Show Gist options
  • Save solnic/473122 to your computer and use it in GitHub Desktop.
Save solnic/473122 to your computer and use it in GitHub Desktop.
# 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