module UTF8Encoding::ObjectSupport

Public Instance Methods

ensure_utf8_array!(array) click to toggle source

Ensures all elements of the given ‘array` are UTF-8, where possible.

# File lib/ndr_support/utf8_encoding/object_support.rb, line 25
def ensure_utf8_array!(array)
  array.each { |element| ensure_utf8_object!(element) }
end
ensure_utf8_hash!(hash) click to toggle source

Ensures all values of the given ‘hash` are UTF-8, where possible.

# File lib/ndr_support/utf8_encoding/object_support.rb, line 20
def ensure_utf8_hash!(hash)
  hash.each_value { |value| ensure_utf8_object!(value) }
end
ensure_utf8_object!(object) click to toggle source

Recursively ensure the correct encoding is being used:

# File lib/ndr_support/utf8_encoding/object_support.rb, line 6
def ensure_utf8_object!(object)
  case object
  when String
    ensure_utf8!(object)
  when Hash
    ensure_utf8_hash!(object)
  when Array
    ensure_utf8_array!(object)
  else
    object
  end
end