Created
January 6, 2010 22:27
-
-
Save smerritt/270746 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
dm_version = '=0.10.2' | |
gem 'dm-core', dm_version | |
gem "dm-aggregates", dm_version | |
gem "dm-migrations", dm_version | |
gem "dm-timestamps", dm_version | |
gem "dm-types", dm_version | |
gem "dm-validations", dm_version | |
gem "data_objects", '=0.10' | |
gem "do_sqlite3", '=0.10' |
This file contains hidden or 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
# model configuration =============================================== | |
require 'vendor/gems/environment' | |
Bundler.require_env | |
DataMapper.setup(:default, 'sqlite3:///tmp/some.db') | |
# attendance models ================================================= | |
# uses Datamapper (MySQL) | |
require 'ruby-debug' | |
class Attendee | |
include DataMapper::Resource | |
belongs_to :raid#, :child_key => "raid_id" | |
belongs_to :player#, :child_key => "player_id" | |
belongs_to :instance#, :child_key => "instance_id" | |
belongs_to :rank#, :child_key => "rank_id" | |
property :attendee_id, Serial, :key => true | |
property :notes, String, :length => 1024 | |
property :shutout, Boolean, :default => false | |
property :status, String | |
property :date, Date | |
end | |
class Instance | |
include DataMapper::Resource | |
has n, :attendees | |
has n, :raids | |
property :instance_id, Serial, :key => true | |
property :instance, String | |
property :abbreviation, String | |
property :status, String | |
property :active, Boolean, :default => true | |
property :size, Integer | |
end | |
class Player | |
include DataMapper::Resource | |
has n, :attendees | |
belongs_to :rank#, :child_key => "rank_id" | |
property :player_id, Serial, :key => true | |
property :name, String | |
property :klass, String, :field => "class" | |
property :role, String | |
property :is_leader, Boolean, :default => false | |
property :alt_of, String | |
end | |
class Raid | |
include DataMapper::Resource | |
has n, :attendees | |
belongs_to :instance#, :child_key => "instance_id" | |
property :raid_id, Serial, :key => true | |
property :date, Date | |
property :status, String | |
property :wws_link, String | |
property :entered_by, String | |
end | |
class Rank | |
include DataMapper::Resource | |
# has n, :attendees | |
has n, :players | |
property :rank_id, Serial, :key => true | |
property :rank, String | |
property :rank_num, Integer | |
end | |
DataMapper.auto_migrate! | |
rank = Rank.create( | |
:rank => 'positively wizardly', | |
:rank_num => 1) | |
player = rank.players.create( | |
:name => 'Bob Dingnagian', | |
:klass => '1988', | |
:role => 'sous chef', | |
:alt_of => 'meta key is usually labeled alt') | |
instance = Instance.create( | |
:abbreviation => 'inst', | |
:size => 4) | |
raid = instance.raids.create(:status => 'kills bugs dead') | |
attendee = player.attendees.create( | |
:raid => raid, | |
:rank => rank, | |
:player => player, | |
:instance => instance, | |
:notes => 'truant') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment