Class: Card::Codename

Inherits:
Object show all
Defined in:
lib/card/codename.rb

Constant Summary collapse

@@codehash =
nil

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

returns codename for id and vice versa. not in love with this api –efm



11
12
13
14
15
# File 'lib/card/codename.rb', line 11

def [] key
  return if key.nil?
  key = key.to_sym unless key.is_a? Integer
  codehash[key]
end

.bootdata(hash) ⇒ Object

only used in migration



27
28
29
# File 'lib/card/codename.rb', line 27

def bootdata hash
  @@codehash = hash
end

.codehashObject



17
18
19
# File 'lib/card/codename.rb', line 17

def codehash
  @@codehash || load_hash
end

.reset_cacheObject



21
22
23
24
# File 'lib/card/codename.rb', line 21

def reset_cache
  @@codehash = nil
  cache.write 'CODEHASH', nil
end