def check_attachments(doc, fatal=true)

      return unless doc['_attachments']

      doc['_attachments'].values.each do |att|

        fail ArgumentError.new(
          'cannot have attachments that are stubs (missing stub)'
        ) if fatal && att['stub'] == true

        att.delete('revpos') # else the attachment gets discarded
      end

      doc['_attachments'].delete_if { |name, att| att['stub'] == true }
    end
def check_attachments(doc, fatal=true)

      return unless doc['_attachments']

      doc['_attachments'].values.each do |att|

        fail ArgumentError.new(
          'cannot have attachments that are stubs (missing stub)'
        ) if fatal && att['stub'] == true

        att.delete('revpos') # else the attachment gets discarded
      end

      doc['_attachments'].delete_if { |name, att| att['stub'] == true }
    end
Will raise if there is an attachment with "stub: true", and will
 also make sure to remove any 'revpos' attribute (when this attribute
 is present, attachments get discarded at #put and #bulk_put.

 If fatal == false, no ArgumentError will be raised, but the stub
 attachments will get discarded.