Platform cloning (untested)

This commit is contained in:
Alexey Nayden 2011-03-11 20:38:28 +03:00
parent 06d229a4b0
commit 9a91224d91
3 changed files with 25 additions and 0 deletions

View File

@ -11,6 +11,16 @@ class Platform < ActiveRecord::Base
build_path(unixname)
end
def clone(new_name, new_unixname)
p = Platform.new
p.name = new_name
p.unixname = new_unixname
p.parent = self
p.repositories = repositories.map(&:clone)
p.save!
return p
end
protected
def build_path(dir)

View File

@ -17,6 +17,13 @@ class Project < ActiveRecord::Base
build_path(unixname)
end
def clone
p = Project.new
p.name = name
p.unixname = unixname
return p
end
protected
def build_path(dir)

View File

@ -11,6 +11,14 @@ class Repository < ActiveRecord::Base
build_path(unixname)
end
def clone
r = Repository.new
r.name = name
r.unixname = unixname
r.projects = projects.map(&:clone)
return r
end
protected
def build_path(dir)