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