Class: Clockwork::ManagerWithDatabaseTasks
- Defined in:
- lib/clockwork/manager_with_database_tasks.rb
Instance Attribute Summary
Attributes inherited from Manager
Instance Method Summary collapse
-
#initialize ⇒ ManagerWithDatabaseTasks
constructor
A new instance of ManagerWithDatabaseTasks.
- #sync_database_tasks(options = {}, &block) ⇒ Object
Methods inherited from Manager
#configure, #default_configuration, #error_handler, #every, #fire_callbacks, #handle_error, #handler, #log, #log_error, #on, #run, #thread_available?, #tick
Constructor Details
#initialize ⇒ ManagerWithDatabaseTasks
Returns a new instance of ManagerWithDatabaseTasks.
110 111 112 113 |
# File 'lib/clockwork/manager_with_database_tasks.rb', line 110 def initialize super @database_event_sync_performers = [] end |
Instance Method Details
#sync_database_tasks(options = {}, &block) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/clockwork/manager_with_database_tasks.rb', line 115 def sync_database_tasks(={}, &block) [:model, :every].each do |option| raise ArgumentError.new("requires :#{option} option") unless .include?(option) end raise ArgumentError.new(":every must be greater or equal to 1.minute") if [:every] < 1.minute sync_performer = DatabaseEventSyncPerformer.new(self, [:model], block) @database_event_sync_performers << sync_performer # create event that syncs clockwork events with database events every [:every], "sync_database_tasks_for_model_#{[:model]}" do sync_performer.sync end end |