Created
January 12, 2010 21:37
-
-
Save antw/275638 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
module DataMapper | |
module Mongo | |
module Model | |
# ... | |
# Defines a Property on the Resource | |
# | |
# Overrides the property method in dm-core so as to automatically map | |
# Array and Hash types to EmbeddedArray and EmbeddedHash respectively. | |
# | |
# @param [Symbol] name | |
# the name for which to call this property | |
# @param [Type] type | |
# the type to define this property ass | |
# @param [Hash(Symbol => String)] options | |
# a hash of available options | |
# | |
# @return [Property] | |
# the created Property | |
# | |
# @api public | |
def property(name, type, options = {}) | |
if Array == type | |
type = DataMapper::Mongo::Types::EmbeddedArray | |
elsif Hash == type | |
type = DataMapper::Mongo::Types::EmbeddedHash | |
end | |
super(name, type, options) | |
end | |
end # Model | |
end # Mongo | |
end # DataMapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment