2014-01-16 17:03:42 +00:00
|
|
|
class BaseService
|
2012-07-20 05:39:34 +00:00
|
|
|
attr_accessor :project, :current_user, :params
|
|
|
|
|
2014-09-21 08:29:52 +00:00
|
|
|
def initialize(project, user, params = {})
|
2012-07-20 05:39:34 +00:00
|
|
|
@project, @current_user, @params = project, user, params.dup
|
|
|
|
end
|
2012-07-28 00:35:24 +00:00
|
|
|
|
|
|
|
def abilities
|
2014-10-19 08:50:23 +00:00
|
|
|
Ability.abilities
|
2012-07-28 00:35:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def can?(object, action, subject)
|
|
|
|
abilities.allowed?(object, action, subject)
|
|
|
|
end
|
2014-04-02 10:38:35 +00:00
|
|
|
|
|
|
|
def notification_service
|
|
|
|
NotificationService.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_service
|
|
|
|
EventCreateService.new
|
|
|
|
end
|
|
|
|
|
2014-09-25 22:07:40 +00:00
|
|
|
def log_info(message)
|
2014-04-02 10:38:35 +00:00
|
|
|
Gitlab::AppLogger.info message
|
|
|
|
end
|
2014-06-17 19:20:10 +00:00
|
|
|
|
|
|
|
def system_hook_service
|
|
|
|
SystemHooksService.new
|
|
|
|
end
|
2014-09-21 08:29:52 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def error(message)
|
|
|
|
{
|
|
|
|
message: message,
|
|
|
|
status: :error
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def success
|
|
|
|
{
|
|
|
|
status: :success
|
|
|
|
}
|
|
|
|
end
|
2012-07-20 05:39:34 +00:00
|
|
|
end
|