Skip to content

Instantly share code, notes, and snippets.

Created May 20, 2009 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/114960 to your computer and use it in GitHub Desktop.
Save anonymous/114960 to your computer and use it in GitHub Desktop.
class GameMode
include DataMapper::Resource
property :id, Serial
property :title, String
property :description, Text
property :max_players, Integer
has n, :game_mode_types
has n, :game_mode_matches
has n, :parents, :through => :game_mode_matches, :class_name => 'GameMode',
:remote_name => :parent, :child_key => [:parent_id]
has n, :children, :through => :game_mode_matches, :class_name => 'GameMode',
:remote_name => :child, :child_key => [:child_id]
belongs_to :game
end
class GameModeMatch
include DataMapper::Resource
property :parent_id, Integer, :key => true
property :child_id, Integer, :key => true
belongs_to :parent, :class_name => 'GameMode', :child_key => [:parent_id]
belongs_to :child, :class_name => 'GameMode', :child_key => [:child_id]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment