Class: Karafka::Web::Ui::Models::Jobs
- Inherits:
-
Object
- Object
- Karafka::Web::Ui::Models::Jobs
- 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
-
#each(&block) ⇒ Object
Allows for iteration over jobs.
-
#initialize(jobs_array) ⇒ Jobs
constructor
A new instance of Jobs.
-
#pending ⇒ Jobs
Pending jobs.
-
#running ⇒ Jobs
Running jobs.
-
#select(&block) ⇒ Jobs
Creates a new Jobs object with selected jobs.
Constructor Details
#initialize(jobs_array) ⇒ Jobs
Returns a new instance of Jobs.
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
41 42 43 |
# File 'lib/karafka/web/ui/models/jobs.rb', line 41 def each(&block) @jobs_array.each(&block) end |
#pending ⇒ Jobs
Returns pending jobs.
28 29 30 |
# File 'lib/karafka/web/ui/models/jobs.rb', line 28 def pending select { |job| job.status == 'pending' } end |
#running ⇒ Jobs
Returns 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
35 36 37 |
# File 'lib/karafka/web/ui/models/jobs.rb', line 35 def select(&block) self.class.new(super(&block)) end |