def cast(parent, value)
      return value unless casted
      if type.is_a?(Array)
        # Convert to array if it is not already
        value = [value].compact unless value.is_a?(Array)
        arr = value.collect { |data| cast_value(parent, data) }
        # allow casted_by calls to be passed up chain by wrapping in CastedArray
        value = type_class != String ? ::CouchRest::CastedArray.new(arr, self) : arr
        value.casted_by = parent if value.respond_to?(:casted_by)
      elsif !value.nil?
        value = cast_value(parent, value)
      end
      value
    end
def cast(parent, value)
      return value unless casted
      if type.is_a?(Array)
        # Convert to array if it is not already
        value = [value].compact unless value.is_a?(Array)
        arr = value.collect { |data| cast_value(parent, data) }
        # allow casted_by calls to be passed up chain by wrapping in CastedArray
        value = type_class != String ? ::CouchRest::CastedArray.new(arr, self) : arr
        value.casted_by = parent if value.respond_to?(:casted_by)
      elsif !value.nil?
        value = cast_value(parent, value)
      end
      value
    end
Cast the provided value using the properties details.