Class: Gitlab::Issuable::Clone::AttributesRewriter
- Inherits:
-
Object
- Object
- Gitlab::Issuable::Clone::AttributesRewriter
- Defined in:
- lib/gitlab/issuable/clone/attributes_rewriter.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#original_entity ⇒ Object
readonly
Returns the value of attribute original_entity.
-
#target_parent ⇒ Object
readonly
Returns the value of attribute target_parent.
Instance Method Summary collapse
- #execute(include_milestone: true) ⇒ Object
-
#initialize(current_user, original_entity, target_parent) ⇒ AttributesRewriter
constructor
A new instance of AttributesRewriter.
Constructor Details
#initialize(current_user, original_entity, target_parent) ⇒ AttributesRewriter
Returns a new instance of AttributesRewriter.
9 10 11 12 13 14 15 |
# File 'lib/gitlab/issuable/clone/attributes_rewriter.rb', line 9 def initialize(current_user, original_entity, target_parent) raise ArgumentError, 'target_parent cannot be nil' if target_parent.nil? @current_user = current_user @original_entity = original_entity @target_parent = target_parent end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
7 8 9 |
# File 'lib/gitlab/issuable/clone/attributes_rewriter.rb', line 7 def current_user @current_user end |
#original_entity ⇒ Object (readonly)
Returns the value of attribute original_entity.
7 8 9 |
# File 'lib/gitlab/issuable/clone/attributes_rewriter.rb', line 7 def original_entity @original_entity end |
#target_parent ⇒ Object (readonly)
Returns the value of attribute target_parent.
7 8 9 |
# File 'lib/gitlab/issuable/clone/attributes_rewriter.rb', line 7 def target_parent @target_parent end |
Instance Method Details
#execute(include_milestone: true) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gitlab/issuable/clone/attributes_rewriter.rb', line 17 def execute(include_milestone: true) attributes = { label_ids: cloneable_labels.pluck_primary_key } if include_milestone milestone = matching_milestone(original_entity.milestone&.title) attributes[:milestone_id] = milestone.id if milestone.present? end attributes end |