Module: Card::Name::CardClass

Included in:
Card
Defined in:
card/lib/card/name/card_class.rb

Overview

Name-related Card class methods

Instance Method Summary collapse

Instance Method Details

#rename!(oldname, newname) ⇒ Object



5
6
7
# File 'card/lib/card/name/card_class.rb', line 5

def rename! oldname, newname
  Card[oldname].update! name: newname, update_referers: true
end

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



9
10
11
12
13
14
15
16
17
# File 'card/lib/card/name/card_class.rb', line 9

def uniquify_name name, rename=:new
  return name unless Card.exists? name

  uniq_name = generate_alternative_name name
  return uniq_name unless rename == :old

  rename!(name, uniq_name)
  name
end