Created
November 26, 2010 12:18
-
-
Save pathsny/716637 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
class Pet | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
property :type, Discriminator, :required => true, :index => true | |
end | |
class Dog < Pet | |
end | |
class Human | |
include DataMapper::Resource | |
property :id, Serial | |
has n, :pets | |
end | |
DataMapper.finalize | |
h = Human.new(:pets => [Pet.new(:name => "nemo"), Dog.new(:name => "fido")]) | |
h.pets.first(:type => Dog) # => nil | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment