Class: Docket::RoundRobin

Inherits:
Object
  • Object
show all
Defined in:
lib/docket/round_robin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ RoundRobin

Returns a new instance of RoundRobin.



6
7
8
# File 'lib/docket/round_robin.rb', line 6

def initialize args={}
  @storage = args[:storage] || Docket.configuration.storage || Docket::Storage::Daybreak.new('/tmp/docket.rb')
end

Instance Attribute Details

#storageObject

Returns the value of attribute storage.



4
5
6
# File 'lib/docket/round_robin.rb', line 4

def storage
  @storage
end

Instance Method Details

#perform(identifier, action) ⇒ Object



14
15
16
17
18
# File 'lib/docket/round_robin.rb', line 14

def perform identifier, action
  robin = next_robin identifier
  action.call(robin)
  robin
end

#reset!Object



25
26
27
# File 'lib/docket/round_robin.rb', line 25

def reset!
  storage.clear!
end

#set(identifier, robins, options = {}) ⇒ Object



10
11
12
# File 'lib/docket/round_robin.rb', line 10

def set identifier, robins, options={}
  save identifier, robins, options
end

#unset(identifier) ⇒ Object



20
21
22
23
# File 'lib/docket/round_robin.rb', line 20

def unset identifier
  unset_key identifier
  unset_from_groups identifier
end