Merge pull request #517 from warpc/207-platform_clone

[refs #207] Fix platform clone. Always set released to false for target platform.
This commit is contained in:
Vladimir Sharshov 2012-06-08 10:45:26 -07:00
commit 6435817163
3 changed files with 8 additions and 9 deletions

View File

@ -104,11 +104,10 @@ class Platform < ActiveRecord::Base
end
def base_clone(attrs = {}) # :description, :name, :owner
clone.tap do |c|
# c.attributes = attrs #
attrs.each {|k,v| c.send("#{k}=", v)}
c.updated_at = nil; c.created_at = nil # :id = nil
c.parent = self
dup.tap do |c|
attrs.each {|k,v| c.send("#{k}=", v)} # c.attributes = attrs
c.updated_at = nil; c.created_at = nil
c.parent = self; c.released = false
end
end

View File

@ -54,10 +54,10 @@ class Product < ActiveRecord::Base
end
def full_clone(attrs = {})
clone.tap do |c| # dup
dup.tap do |c|
c.platform_id = nil
attrs.each {|k,v| c.send("#{k}=", v)}
c.updated_at = nil; c.created_at = nil # :id = nil
c.updated_at = nil; c.created_at = nil
end
end

View File

@ -17,10 +17,10 @@ class Repository < ActiveRecord::Base
attr_readonly :name, :platform_id
def base_clone(attrs = {})
clone.tap do |c| # dup
dup.tap do |c|
c.platform_id = nil
attrs.each {|k,v| c.send("#{k}=", v)}
c.updated_at = nil; c.created_at = nil # :id = nil
c.updated_at = nil; c.created_at = nil
end
end