Class: Issuable::BulkUpdateService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Allowable
Defined in:
app/services/issuable/bulk_update_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(parent, user = nil, params = {}) ⇒ BulkUpdateService

Returns a new instance of BulkUpdateService.


9
10
11
# File 'app/services/issuable/bulk_update_service.rb', line 9

def initialize(parent, user = nil, params = {})
  @parent, @current_user, @params = parent, user, params.dup
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


7
8
9
# File 'app/services/issuable/bulk_update_service.rb', line 7

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params


7
8
9
# File 'app/services/issuable/bulk_update_service.rb', line 7

def params
  @params
end

#parentObject

Returns the value of attribute parent


7
8
9
# File 'app/services/issuable/bulk_update_service.rb', line 7

def parent
  @parent
end

Instance Method Details

#execute(type) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'app/services/issuable/bulk_update_service.rb', line 13

def execute(type)
  ids = params.delete(:issuable_ids).split(",")
  set_update_params(type)
  items = update_issuables(type, ids)

  response_success(payload: { count: items.count })
rescue ArgumentError => e
  response_error(e.message, 422)
end