2012-03-04 15:35:15 +02:00
|
|
|
class KeyObserver < ActiveRecord::Observer
|
2012-08-29 00:04:06 +03:00
|
|
|
include GitHost
|
|
|
|
|
2012-03-04 15:35:15 +02:00
|
|
|
def after_save(key)
|
2012-08-29 00:04:06 +03:00
|
|
|
git_host.set_key(key.identifier, key.key, key.projects)
|
2012-03-04 15:35:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_destroy(key)
|
2012-08-29 00:04:06 +03:00
|
|
|
return if key.is_deploy_key && !key.last_deploy?
|
|
|
|
git_host.remove_key(key.identifier, key.projects)
|
2012-03-04 15:35:15 +02:00
|
|
|
end
|
|
|
|
end
|