Created
January 30, 2014 22:09
-
-
Save theCrab/8721016 to your computer and use it in GitHub Desktop.
How to implement the GitHub Orgs, Users, Repo Access Control Level using DataMapper.
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 Organisation | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String, length: 3..15 | |
timestamps :created_at, :updated_at | |
belongs_to :user | |
has n, :teams | |
has n, :users, through: :teams | |
end | |
class User | |
property :id, Serial | |
property :username, String | |
has n, :organisations | |
has n, :teams | |
end | |
class Team | |
## Team is used to manage vehicles | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String, required: true | |
property :permission, Enum[:owner, :garage, :driver, :dispatcher], default: :driver | |
belongs_to :organisation | |
has n, :members, class: 'User', child_key: :member_id | |
end | |
class Vehicle # On GitHub, this is similar to a Repository | |
include DataMapper::Resource | |
property :id, Serial | |
property :vin, String, required: true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment