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.
-
.syslog_warning(message) ⇒ Object
Syslogs a warning message.
-
.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.
64 65 66 67 68 |
# File 'lib/rbeapi/utils.rb', line 64 def self.class_from_string(name) name.split('::').inject(Object) do |mod, cls| mod.const_get(cls) end end |
.syslog_warning(message) ⇒ Object
Syslogs a warning message.
74 75 76 |
# File 'lib/rbeapi/utils.rb', line 74 def self.syslog_warning() Syslog.open('rbeapi', Syslog::LOG_PID) { |s| s.warning } end |
.transform_keys_to_symbols(value) ⇒ Hash
Iterates through a hash structure and converts all of the keys to symbols.
49 50 51 52 53 54 55 56 |
# File 'lib/rbeapi/utils.rb', line 49 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 |