Class: Organizations::UpdateService
- Inherits:
-
BaseService
- Object
- BaseService
- Organizations::UpdateService
- Defined in:
- app/services/organizations/update_service.rb
Instance Attribute Summary collapse
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(organization, current_user:, params: {}) ⇒ UpdateService
constructor
A new instance of UpdateService.
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(organization, current_user:, params: {}) ⇒ UpdateService
Returns a new instance of UpdateService.
7 8 9 10 11 12 13 14 15 |
# File 'app/services/organizations/update_service.rb', line 7 def initialize(organization, current_user:, params: {}) @organization = organization @current_user = current_user @params = params.dup build_organization_detail_attributes # TODO: Remove explicit passing of id once https://github.com/rails/rails/issues/48714 is resolved. @params[:organization_detail_attributes][:id] = organization.id end |
Instance Attribute Details
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
5 6 7 |
# File 'app/services/organizations/update_service.rb', line 5 def organization @organization end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/organizations/update_service.rb', line 17 def execute return unless allowed? if params[:organization_detail_attributes].key?(:avatar) && params[:organization_detail_attributes][:avatar].nil? organization.remove_avatar! end if organization.update(params) ServiceResponse.success(payload: { organization: organization }) else error_updating end end |