def __convert_value_to_hash(value, options = {})
      case
      # Converts Bag instance to Hash
      when value.kind_of?(Bag)
        value.to_hash(options)

      # Converts Array elements to Hash instances if needed
      when value.kind_of?(Array)
        value.map { |value| __convert_value_to_hash(value, options) }

      # Keeps as-is other elements
      else
        value
      end
    end
def __convert_value_to_hash(value, options = {})
      case
      # Converts Bag instance to Hash
      when value.kind_of?(Bag)
        value.to_hash(options)

      # Converts Array elements to Hash instances if needed
      when value.kind_of?(Array)
        value.map { |value| __convert_value_to_hash(value, options) }

      # Keeps as-is other elements
      else
        value
      end
    end
This function does the reversion of value conversion to Bag
 instances. It transforms Bag instances to Hash (using to_hash)
 and array Bag elements to Hash (using to_hash).

 The options parameters are pass to the to_hash function
 when invoked.

 @param value The value to convert to hash
 @param options The options passed to the to_hash function
 @return The converted value