module Rbeapi::Utils
Utils
module.
Public Class Methods
class_from_string(name)
click to toggle source
Returns a class object from a string capable of being instatiated.
@param name [String] The name of the class to return a constant for.
@return [Object] Returns a a class object that can be instatiated.
# 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)
click to toggle source
Syslogs a warning message.
@param message [String] The message to log.
# File lib/rbeapi/utils.rb, line 74 def self.syslog_warning(message) Syslog.open('rbeapi', Syslog::LOG_PID) { |s| s.warning message } end
transform_keys_to_symbols(value)
click to toggle source
Iterates through a hash structure and converts all of the keys to symbols.
@param value [Hash] The hash structure to convert the keys.
@return [Hash] An updated hash structure with all keys converted to
symboles.
# 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