class Generic
Represents a generic job interface that defines the minimum required structure for jobs. This class serves as a base for implementing specific job types and provides common functionality for job identification and scheduling.
Definitions
def self.enqueue(...)
Create and enqueue a new job with the given parameters.
Signature
-
parameter
...
Object
Parameters to pass to the job constructor.
-
returns
Async::Job::Generic
The created and enqueued job.
Implementation
def self.enqueue(...)
self.new(...).enqueue
end
def initialize(id, scheduled_at: nil)
Initialize a new generic job.
Signature
-
parameter
id
Object
The unique identifier for this job.
-
option
scheduled_at
Time | nil
The time when this job should be executed.
Implementation
def initialize(id, scheduled_at: nil)
@id = id
@scheduled_at = scheduled_at
end
attr :id
Signature
-
attribute
Object
The unique identifier for this job.
attr :scheduled_at
Signature
-
attribute
Time | nil
The scheduled execution time for this job.
def serialize
Serialize the job for storage or transmission. This method must be implemented by subclasses.
Signature
-
raises
NotImplementedError
Always raised, must be implemented by subclasses.
Implementation
def serialize
raise NotImplementedError
end
def call
Execute the job. This method must be implemented by subclasses.
Signature
-
raises
NotImplementedError
Always raised, must be implemented by subclasses.
Implementation
def call
raise NotImplementedError
end