Class: Clockwork::DatabaseEvents::EventCollection
- Inherits:
-
Object
- Object
- Clockwork::DatabaseEvents::EventCollection
- Defined in:
- lib/clockwork/database_events/event_collection.rb
Instance Method Summary collapse
- #add(event) ⇒ Object
- #has_changed?(model) ⇒ Boolean
-
#initialize(manager = Clockwork.manager) ⇒ EventCollection
constructor
A new instance of EventCollection.
- #unregister ⇒ Object
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
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 |
#unregister ⇒ Object
22 23 24 |
# File 'lib/clockwork/database_events/event_collection.rb', line 22 def unregister events.each{|e| manager.unregister(e) } end |