Module: Marty::Enum

Included in:
PostingType, Role
Defined in:
app/models/marty/enum.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'app/models/marty/enum.rb', line 2

def [](index)
  @LOOKUP_CACHE ||= {}

  index = index.to_s

  res = @LOOKUP_CACHE[index] ||= find_by_name(index)

  raise "no such #{self.name}: '#{index}'" unless res

  res
end

#clear_lookup_cache!Object



14
15
16
# File 'app/models/marty/enum.rb', line 14

def clear_lookup_cache!
  @LOOKUP_CACHE.clear if @LOOKUP_CACHE
end