Sha256: f3d7b829c077720c2a26164f83e3384c8a5e405c1e527e39ab00810b53e55324
Contents?: true
Size: 374 Bytes
Versions: 25
Compression:
Stored size: 374 Bytes
Contents
module Marty::Enum def [](index) @LOOKUP_CACHE ||= {} index = index.to_s res = @LOOKUP_CACHE[index] ||= find_by_name(index) return res if res raise "no such #{self.name}: '#{index}'" end def to_s # FIXME: hacky since not all enums have name self.name end def clear_lookup_cache! @LOOKUP_CACHE.clear if @LOOKUP_CACHE end end
Version data entries
25 entries across 25 versions & 1 rubygems