class ChefCLI::Policyfile::UndoStack

def push(undo_record)

def push(undo_record)
  ensure_undo_dir_exists
  record_id = Time.new.utc.strftime("%Y%m%d%H%M%S")
  path = File.join(undo_dir, record_id)
  with_file(path) do |f|
    f.print(FFI_Yajl::Encoder.encode(undo_record.for_serialization, pretty: true))
  end
  records_to_delete = undo_record_files.size - MAX_SIZE
  if records_to_delete > 0
    undo_record_files.take(records_to_delete).each do |file|
      File.unlink(file)
    end
  end
  self
end