Class: Karafka::Web::Ui::Models::Jobs

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/karafka/web/ui/models/jobs.rb

Overview

Model representing group of jobs

It simplifies filtering on running jobs and others, etc

Instance Method Summary collapse

Constructor Details

#initialize(jobs_array) ⇒ Jobs

Returns a new instance of Jobs.

Parameters:

  • jobs_array (Array<Job>)

    all jobs we want to enclose



18
19
20
# File 'lib/karafka/web/ui/models/jobs.rb', line 18

def initialize(jobs_array)
  @jobs_array = jobs_array
end

Instance Method Details

#each(&block) ⇒ Object

Allows for iteration over jobs

Parameters:

  • block (Proc)

    block to call for each job



41
42
43
# File 'lib/karafka/web/ui/models/jobs.rb', line 41

def each(&block)
  @jobs_array.each(&block)
end

#pendingJobs

Returns pending jobs.

Returns:

  • (Jobs)

    pending jobs



28
29
30
# File 'lib/karafka/web/ui/models/jobs.rb', line 28

def pending
  select { |job| job.status == 'pending' }
end

#runningJobs

Returns running jobs.

Returns:

  • (Jobs)

    running jobs



23
24
25
# File 'lib/karafka/web/ui/models/jobs.rb', line 23

def running
  select { |job| job.status == 'running' }
end

#select(&block) ⇒ Jobs

Creates a new Jobs object with selected jobs

Parameters:

  • block (Proc)

    select proc

Returns:

  • (Jobs)

    selected jobs enclosed with the Jobs object



35
36
37
# File 'lib/karafka/web/ui/models/jobs.rb', line 35

def select(&block)
  self.class.new(super(&block))
end