Sha256: 6f201f0be183aa3c079cd770dd12ea7517dfbe844fa433a4646d46f497f9d4ec
Contents?: true
Size: 1.73 KB
Versions: 6
Compression:
Stored size: 1.73 KB
Contents
module Lumberg module Whm autoload :Base, 'lumberg/whm/base' autoload :Server, 'lumberg/whm/server' autoload :Account, 'lumberg/whm/account' autoload :Dns, 'lumberg/whm/dns' autoload :Reseller, 'lumberg/whm/reseller' class << self # Converts keys to symbols def symbolize_keys(arg) case arg when Array arg.map { |elem| symbolize_keys elem } when Hash Hash[ arg.map { |key, value| k = key.is_a?(String) ? key.gsub('-', '_').to_sym : key v = symbolize_keys value [k,v] }] else arg end end # Recursively converts values of 0 or 1 to true or false def to_bool(hash, *keys) if keys.empty? keys = [:all] else keys.flatten! end if hash.is_a?(Hash) hash = Hash[ hash.map {|key, value| # recurse value = to_bool(value, keys) if value.is_a?(Hash) value = value.map {|elem| to_bool(elem, keys) } if value.is_a?(Array) if (keys.first == :all) || (keys.include?(key) || (keys.include?(key.to_sym))) value = (value.to_s.match(/0|1/) ? value.to_i == 1 : value) end [key, value] }] end hash end # Converts boolean values to 0 or 1 def from_bool(input) if input == false 0 elsif input == true 1 elsif input.is_a?(Hash) Hash[ input.map {|k,v| v = from_bool(v) [k,v] } ] end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems