Commit 468c8c5f authored by Andrew8xx8's avatar Andrew8xx8

A little bit of codestyle improvments

parent 08f665cf
class SystemHookObserver < ActiveRecord::Observer class SystemHookObserver < ActiveRecord::Observer
observe :user, :project, :users_project observe :user, :project, :users_project
def after_create(model) def after_create(model)
if model.kind_of? Project case model
when Project
SystemHook.all_hooks_fire({ SystemHook.all_hooks_fire({
event_name: "project_create", event_name: "project_create",
name: model.name, name: model.name,
...@@ -12,15 +13,14 @@ class SystemHookObserver < ActiveRecord::Observer ...@@ -12,15 +13,14 @@ class SystemHookObserver < ActiveRecord::Observer
owner_email: model.owner.email, owner_email: model.owner.email,
created_at: model.created_at created_at: model.created_at
}) })
elsif model.kind_of? User when User
SystemHook.all_hooks_fire({ SystemHook.all_hooks_fire({
event_name: "user_create", event_name: "user_create",
name: model.name, name: model.name,
email: model.email, email: model.email,
created_at: model.created_at created_at: model.created_at
}) })
when UsersProject
elsif model.kind_of? UsersProject
SystemHook.all_hooks_fire({ SystemHook.all_hooks_fire({
event_name: "user_add_to_team", event_name: "user_add_to_team",
project_name: model.project.name, project_name: model.project.name,
...@@ -31,12 +31,12 @@ class SystemHookObserver < ActiveRecord::Observer ...@@ -31,12 +31,12 @@ class SystemHookObserver < ActiveRecord::Observer
project_access: model.repo_access_human, project_access: model.repo_access_human,
created_at: model.created_at created_at: model.created_at
}) })
end end
end end
def after_destroy(model) def after_destroy(model)
if model.kind_of? Project case model
when Project
SystemHook.all_hooks_fire({ SystemHook.all_hooks_fire({
event_name: "project_destroy", event_name: "project_destroy",
name: model.name, name: model.name,
...@@ -45,14 +45,13 @@ class SystemHookObserver < ActiveRecord::Observer ...@@ -45,14 +45,13 @@ class SystemHookObserver < ActiveRecord::Observer
owner_name: model.owner.name, owner_name: model.owner.name,
owner_email: model.owner.email, owner_email: model.owner.email,
}) })
elsif model.kind_of? User when User
SystemHook.all_hooks_fire({ SystemHook.all_hooks_fire({
event_name: "user_destroy", event_name: "user_destroy",
name: model.name, name: model.name,
email: model.email email: model.email
}) })
when UsersProject
elsif model.kind_of? UsersProject
SystemHook.all_hooks_fire({ SystemHook.all_hooks_fire({
event_name: "user_remove_from_team", event_name: "user_remove_from_team",
project_name: model.project.name, project_name: model.project.name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment