Class: Issuable::Callbacks::Labels
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/issuable/callbacks/labels.rb
Constant Summary collapse
- ALLOWED_PARAMS =
%i[labels add_labels remove_labels label_ids add_label_ids remove_label_ids].freeze
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#after_create, #after_save, #after_save_commit, #after_update, #after_update_commit, #before_create, #before_update, execute_without_params?, #initialize
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from Issuable::Callbacks::Base
Instance Method Details
#after_initialize ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/issuable/callbacks/labels.rb', line 10 def after_initialize params[:label_ids] = params[:add_label_ids] = [] if excluded_in_new_type? return unless ALLOWED_PARAMS.any? { |param| params.key?(param) } return unless (:"set_#{issuable.to_ability_name}_metadata") normalize_and_filter_label_params! existing_label_ids = issuable.label_ids.sort new_label_ids = compute_new_label_ids.sort issuable.label_ids = new_label_ids issuable.touch if issuable.persisted? && existing_label_ids != new_label_ids end |