Module: Card::Set::All::Name::ClassMethods

Defined in:
tmpsets/set/mod001-core/all/name.rb

Instance Method Summary collapse

Instance Method Details

#uniquify_name(name, rename = :new) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'tmpsets/set/mod001-core/all/name.rb', line 7

def uniquify_name name, rename=:new
  return name unless Card.exists?(name)
  uniq_name = "#{name} 1"
  uniq_name.next! while Card.exists?(uniq_name)
  if rename == :old
    # name conflict resolved; original name can be used
    Card[name].update_attributes! name: uniq_name,
                                  update_referers: true
    name
  else
    uniq_name
  end
end