2012-03-04 14:35:15 +01:00
|
|
|
class KeyObserver < ActiveRecord::Observer
|
2012-08-28 23:04:06 +02:00
|
|
|
include GitHost
|
|
|
|
|
2012-03-04 14:35:15 +01:00
|
|
|
def after_save(key)
|
2012-08-28 23:04:06 +02:00
|
|
|
git_host.set_key(key.identifier, key.key, key.projects)
|
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?
|
|
|
|
git_host.remove_key(key.identifier, key.projects)
|
2012-03-04 14:35:15 +01:00
|
|
|
end
|
|
|
|
end
|