Created
December 21, 2008 18:41
-
-
Save dmilith/38741 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
| class Port | |
| include DataMapper::Resource | |
| belongs_to :rack_app | |
| belongs_to :user | |
| property :id, Serial, :index => true | |
| property :port, Integer, :default => 3000, :nullable => false | |
| property :user_id, Integer, :nullable => true, :index => true | |
| def self.free_ports | |
| self.find( :all, :conditions => ["user_id IS NULL" ], :order => :port ) | |
| end | |
| def self.setup_ports | |
| (3000..4000).each do |port| | |
| Port.new( :port => port ).save! | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment