Class: Clockwork::DatabaseEvents::EventCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(manager = Clockwork.manager) ⇒ EventCollection

Returns a new instance of EventCollection.



5
6
7
8
# File 'lib/clockwork/database_events/event_collection.rb', line 5

def initialize(manager=Clockwork.manager)
  @events = []
  @manager = manager
end

Instance Method Details

#add(event) ⇒ Object



10
11
12
# File 'lib/clockwork/database_events/event_collection.rb', line 10

def add(event)
  @events << event
end

#has_changed?(model) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/clockwork/database_events/event_collection.rb', line 14

def has_changed?(model)
  return true if event.nil?

  (has_name? && name != model.name) ||
    frequency != model.frequency ||
      ats != model_ats(model)
end

#unregisterObject



22
23
24
# File 'lib/clockwork/database_events/event_collection.rb', line 22

def unregister
  events.each{|e| manager.unregister(e) }
end