class EacRubyUtils::Yaml::Sanitizer
def initialize(source)
def initialize(source) @source = source end
def result
def result RESULT_TYPES.each do |type| return send("result_#{type}") if send("result_#{type}?") end source.to_s end
def result_enumerableable
def result_enumerableable source.to_a.map { |child| sanitize_value(child) } end
def result_enumerableable?
def result_enumerableable? source.respond_to?(:to_a) && !source.is_a?(::Hash) end
def result_hashable
def result_hashable source.to_h.to_h { |k, v| [k.to_sym, sanitize_value(v)] } end
def result_hashable?
def result_hashable? source.respond_to?(:to_h) end
def result_nil
def result_nil nil end
def result_nil?
def result_nil? source.nil? end
def result_permitted
def result_permitted source end
def result_permitted?
def result_permitted? (::EacRubyUtils::Yaml.permitted_classes - [::Array, ::Hash]) .any? { |klass| source.is_a?(klass) } end
def sanitize_value(value)
def sanitize_value(value) self.class.new(value).result end