Skip to content

Instantly share code, notes, and snippets.

@dmilith
Created December 21, 2008 18:41
Show Gist options
  • Select an option

  • Save dmilith/38741 to your computer and use it in GitHub Desktop.

Select an option

Save dmilith/38741 to your computer and use it in GitHub Desktop.
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