2012-03-04 14:35:15 +01:00
|
|
|
class KeyObserver < ActiveRecord::Observer
|
2013-01-03 08:06:07 +01:00
|
|
|
include Gitolited
|
2012-08-28 23:04:06 +02:00
|
|
|
|
2012-03-04 14:35:15 +01:00
|
|
|
def after_save(key)
|
2013-01-28 20:02:10 +01:00
|
|
|
GitoliteWorker.perform_async(
|
|
|
|
:set_key,
|
|
|
|
key.identifier,
|
|
|
|
key.key,
|
|
|
|
key.projects.map(&:id)
|
|
|
|
)
|
2012-03-04 14:35:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_destroy(key)
|
2012-08-28 23:04:06 +02:00
|
|
|
return if key.is_deploy_key && !key.last_deploy?
|
2013-01-28 20:02:10 +01:00
|
|
|
|
|
|
|
GitoliteWorker.perform_async(
|
|
|
|
:remove_key,
|
|
|
|
key.identifier,
|
|
|
|
key.projects.map(&:id)
|
|
|
|
)
|
2012-03-04 14:35:15 +01:00
|
|
|
end
|
|
|
|
end
|