class Clockwork::DatabaseEvents::EventCollection
Attributes
events[R]
manager[R]
Public Class Methods
new(manager=Clockwork.manager)
click to toggle source
# File lib/clockwork/database_events/event_collection.rb, line 5 def initialize(manager=Clockwork.manager) @events = [] @manager = manager end
Public Instance Methods
add(event)
click to toggle source
# File lib/clockwork/database_events/event_collection.rb, line 10 def add(event) @events << event end
has_changed?(model)
click to toggle source
# File lib/clockwork/database_events/event_collection.rb, line 14 def has_changed?(model) return true if event.nil? ignored_attributes = model.ignored_attributes if model.respond_to?(:ignored_attributes) ignored_attributes ||= [] model_attributes = model.attributes.select do |k, _| not ignored_attributes.include?(k.to_sym) end event.model_attributes != model_attributes end
unregister()
click to toggle source
# File lib/clockwork/database_events/event_collection.rb, line 27 def unregister events.each{|e| manager.unregister(e) } end
Private Instance Methods
event()
click to toggle source
All events in the same collection (for a model instance) are equivalent so we can use any of them. Only their @at variable will be different, but we don’t care about that here.
# File lib/clockwork/database_events/event_collection.rb, line 38 def event events.first end