Class: Clockwork::DatabaseEvents::Event

Inherits:
Event
  • Object
show all
Defined in:
lib/clockwork/database_events/event.rb

Instance Attribute Summary collapse

Attributes inherited from Event

#job, #last

Instance Method Summary collapse

Methods inherited from Event

#convert_timezone, #run, #run_now?, #thread?

Constructor Details

#initialize(manager, period, job, block, event_store, model_attributes, options = {}) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
14
# File 'lib/clockwork/database_events/event.rb', line 9

def initialize(manager, period, job, block, event_store, model_attributes, options={})
  super(manager, period, job, block, options)
  @event_store = event_store
  @event_store.register(self, job)
  @model_attributes = model_attributes
end

Instance Attribute Details

#event_storeObject

Returns the value of attribute event_store.



7
8
9
# File 'lib/clockwork/database_events/event.rb', line 7

def event_store
  @event_store
end

#model_attributesObject

Returns the value of attribute model_attributes.



7
8
9
# File 'lib/clockwork/database_events/event.rb', line 7

def model_attributes
  @model_attributes
end

Instance Method Details

#frequencyObject



28
29
30
# File 'lib/clockwork/database_events/event.rb', line 28

def frequency
  @period
end

#job_has_name?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/clockwork/database_events/event.rb', line 20

def job_has_name?
  job.respond_to?(:name)
end

#nameObject



16
17
18
# File 'lib/clockwork/database_events/event.rb', line 16

def name
  (job_has_name? && job.name) ? job.name : "#{job.class}:#{job.id}"
end

#to_sObject



24
25
26
# File 'lib/clockwork/database_events/event.rb', line 24

def to_s
  name
end