Module: Rbeapi::Utils
- Defined in:
 - lib/rbeapi/utils.rb
 
Overview
Utils module
Class Method Summary collapse
- 
  
    
      .class_from_string(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a class object from a string capable of being instatiated.
 - 
  
    
      .transform_keys_to_symbols(value)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Iterates through a hash structure and converts all of the keys to symbols.
 
Class Method Details
.class_from_string(name) ⇒ Object
Returns a class object from a string capable of being instatiated
      62 63 64 65 66  | 
    
      # File 'lib/rbeapi/utils.rb', line 62 def self.class_from_string(name) name.split('::').inject(Object) do |mod, cls| mod.const_get(cls) end end  | 
  
.transform_keys_to_symbols(value) ⇒ Hash
Iterates through a hash structure and converts all of the keys to symbols.
      47 48 49 50 51 52 53 54  | 
    
      # File 'lib/rbeapi/utils.rb', line 47 def self.transform_keys_to_symbols(value) return value unless value.is_a?(Hash) hash = value.each_with_object({}) do |(k, v), hsh| hsh[k.to_sym] = transform_keys_to_symbols(v) hsh end hash end  |