Class: PerfectSched::ScheduleCollection

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/perfectsched/schedule_collection.rb

Instance Attribute Summary

Attributes included from Model

#client

Instance Method Summary collapse

Methods included from Model

#config

Constructor Details

#initialize(client) ⇒ ScheduleCollection

Returns a new instance of ScheduleCollection.



24
25
26
# File 'lib/perfectsched/schedule_collection.rb', line 24

def initialize(client)
  super(client)
end

Instance Method Details

#[](key) ⇒ Object

> Schedule



29
30
31
# File 'lib/perfectsched/schedule_collection.rb', line 29

def [](key)
  Schedule.new(@client, key)
end

#add(key, type, options = {}) ⇒ Object

:data => Hash :cron :timezone



52
53
54
# File 'lib/perfectsched/schedule_collection.rb', line 52

def add(key, type, options={})
  @client.add(key, type, options)
end

#closeObject



56
57
58
# File 'lib/perfectsched/schedule_collection.rb', line 56

def close
  client.close
end

#list(options = {}, &block) ⇒ Object



33
34
35
# File 'lib/perfectsched/schedule_collection.rb', line 33

def list(options={}, &block)
  @client.list(options, &block)
end

#poll(options = {}) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/perfectsched/schedule_collection.rb', line 37

def poll(options={})
  options = options.merge({:max_acquire=>1})
  if acquired = poll_multi(options)
    return acquired[0]
  end
  return nil
end

#poll_multi(options = {}) ⇒ Object



45
46
47
# File 'lib/perfectsched/schedule_collection.rb', line 45

def poll_multi(options={})
  @client.acquire(options)
end