Wednesday, July 15, 2026 3:59:22 AM
> server_command.rb
# frozen_string_literal: true

module ESM
  class ServerCommand < ApplicationRecord
    # =============================================================================
    # INITIALIZE
    # =============================================================================

    # =============================================================================
    # DATA STRUCTURE
    # =============================================================================

    attribute :idempotency_key, :uuid
    attribute :command_name, :string
    attribute :arguments, :hash, default: {}
    enum :status, {
      pending: "pending", dispatched: "dispatched", completed: "completed",
      failed: "failed", timed_out: "timed_out"
    }
    attribute :error_message, :string
    attribute :created_at, :datetime
    attribute :updated_at, :datetime

    # =============================================================================
    # ASSOCIATIONS
    # =============================================================================

    belongs_to :user
    belongs_to :server

    # =============================================================================
    # VALIDATIONS
    # =============================================================================

    # =============================================================================
    # CALLBACKS
    # =============================================================================

    # =============================================================================
    # SCOPES
    # =============================================================================

    # =============================================================================
    # CLASS METHODS
    # =============================================================================

    # =============================================================================
    # INSTANCE METHODS
    # =============================================================================

    #
    # Whether the command has reached a terminal state and won't change again.
    #
    # @return [Boolean]
    #
    def settled?
      completed? || failed? || timed_out?
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 43aa0d7