Class: Katello::Glue::Queue
- Inherits:
-
Object
- Object
- Katello::Glue::Queue
- Defined in:
- app/lib/katello/glue/queue.rb
Constant Summary collapse
- STATUS =
%w(pending running failed completed rollbacked)
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
- #all ⇒ Object
- #clear ⇒ Object
- #create(options) ⇒ Object
- #delete(item) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(previous_queue = nil) ⇒ Queue
constructor
we can put more queues sequentially.
- #to_log ⇒ Object
Constructor Details
#initialize(previous_queue = nil) ⇒ Queue
we can put more queues sequentially. E.g. on queue before saving a record, another after saving. If something in later queue fails we roll-back also everything in previous queues.
20 21 22 23 |
# File 'app/lib/katello/glue/queue.rb', line 20 def initialize(previous_queue = nil) @previous_queue = previous_queue @items = [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
14 15 16 |
# File 'app/lib/katello/glue/queue.rb', line 14 def items @items end |
Instance Method Details
#all ⇒ Object
38 39 40 41 42 43 |
# File 'app/lib/katello/glue/queue.rb', line 38 def all ret = [] ret.concat(@previous_queue.all) if @previous_queue ret.concat(items.sort) ret end |
#clear ⇒ Object
48 49 50 |
# File 'app/lib/katello/glue/queue.rb', line 48 def clear @items = [] && true end |
#create(options) ⇒ Object
25 26 27 28 |
# File 'app/lib/katello/glue/queue.rb', line 25 def create() [:status] ||= default_status Glue::Task.new().tap { |t| items << t } end |
#delete(item) ⇒ Object
30 31 32 |
# File 'app/lib/katello/glue/queue.rb', line 30 def delete(item) @items.delete item end |
#find_by_name(name) ⇒ Object
34 35 36 |
# File 'app/lib/katello/glue/queue.rb', line 34 def find_by_name(name) items.each { |task| return task if task.name == name } end |
#to_log ⇒ Object
52 53 54 |
# File 'app/lib/katello/glue/queue.rb', line 52 def to_log all.collect(&:to_log).join ", " end |