Class: WatchList::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/watch_list/utils.rb

Class Method Summary collapse

Class Method Details

.const_to_hash(const) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/watch_list/utils.rb', line 3

def const_to_hash(const)
  hash = {}

  const.constants.map do |c|
    key = c.to_s.gsub(/[A-Z]+/, '_\0').sub(/\A_/, '').downcase
    hash[key] = const.const_get(c)
  end

  hash
end