Module: Quebert::Support

Defined in:
lib/quebert/support.rb,
lib/quebert/support/pid_file.rb,
lib/quebert/support/registry.rb

Defined Under Namespace

Classes: ClassRegistry, PidFile, Registry

Class Method Summary collapse

Class Method Details

.constantize(camel_cased_word) ⇒ Object

Borrowed from Rails ActiveSupport



8
9
10
11
12
13
14
15
16
17
# File 'lib/quebert/support.rb', line 8

def self.constantize(camel_cased_word) #:nodoc:
  names = camel_cased_word.to_s.split('::')
  names.shift if names.empty? || names.first.empty?
  
  constant = Object
  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end

.stringify_keys(hash) ⇒ Object



23
24
25
# File 'lib/quebert/support.rb', line 23

def self.stringify_keys(hash)
  map_keys(hash, :to_s)
end

.symbolize_keys(hash) ⇒ Object



19
20
21
# File 'lib/quebert/support.rb', line 19

def self.symbolize_keys(hash)
  map_keys(hash, :to_sym)
end