Skip to content

Instantly share code, notes, and snippets.

@durango
Created July 31, 2011 13:28
Show Gist options
  • Save durango/1116798 to your computer and use it in GitHub Desktop.
Save durango/1116798 to your computer and use it in GitHub Desktop.
class Mailbox
include DataMapper::Resource
property :id, Serial
property :title, String, :required => true, :length => 1..30
property :message, Text, :required => true, :length => 1..3000
property :date_sent, DateTime, :default => proc { DateTime.now }
belongs_to :to, 'Player'
belongs_to :from, 'Player'
end
class Player
[snip]
has n, :inbox, 'Mailbox', :child_key => :to_id
has n, :outbox, 'Mailbox', :child_key => :from_id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment