rosa-build/app/models/event_log_observer.rb

26 lines
947 B
Ruby
Raw Normal View History

class EventLogObserver < ActiveRecord::Observer
2014-03-06 11:24:33 +00:00
observe :user, :platform, :repository, :project, :product, :build_list, :product_build_list
def after_create(record)
2014-01-21 04:51:49 +00:00
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
end
def before_update(record)
case record.class.to_s
when 'BuildList'
if record.status_changed? and [BuildList::BUILD_CANCELED, BuildList::BUILD_PUBLISHED].include?(record.status)
2014-01-21 04:51:49 +00:00
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
end
when 'Platform'
if record.visibility_changed?
2014-01-21 04:51:49 +00:00
ActiveSupport::Notifications.instrument "event_log.observer", eventable: record,
message: I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
end
end
end
def after_destroy(record)
2014-01-21 04:51:49 +00:00
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
end
end