Skip to content

Instantly share code, notes, and snippets.

@skord
Created January 12, 2012 13:24
Show Gist options
  • Select an option

  • Save skord/1600502 to your computer and use it in GitHub Desktop.

Select an option

Save skord/1600502 to your computer and use it in GitHub Desktop.
Inventory
require 'dm-core'
require 'dm-migrations'
DataMapper.setup(:default, 'sqlite:///Users/mike/src/corpinv/corpinv.db')
# DataMapper.setup(:default, 'sqlite::memory:')
class Region
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :constellations
end
class Constellation
include DataMapper::Resource
property :id, Serial
property :name, String
belongs_to :region
has n, :solarsystems
end
class Solarsystem
include DataMapper::Resource
property :id, Serial
property :name, String
belongs_to :constellation
has n, :planets
end
class Planet
include DataMapper::Resource
property :id, Serial
property :name, String
property :celestial_index, Integer
property :makeup, String
property :radius, Decimal
belongs_to :solarsystem
has n, :moons
has n, :customs_offices
end
class Moon
include DataMapper::Resource
property :id, Serial
property :name, String
property :orbit_index, Integer
property :radius, Decimal
belongs_to :planet
has n, :minerals, :through => Resource
end
class Mineral
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :moons, :through => Resource
end
class CustomsOffice
include DataMapper::Resource
property :id, Serial
property :name, String
belongs_to :planet
def owner
'TEST Alliance'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment