Class: Gitlab::DataBuilder::Issuable
- Inherits:
-
Object
- Object
- Gitlab::DataBuilder::Issuable
- Defined in:
- lib/gitlab/data_builder/issuable.rb
Constant Summary collapse
- CHANGES_KEYS =
%i[previous current].freeze
Instance Attribute Summary collapse
-
#issuable ⇒ Object
readonly
Returns the value of attribute issuable.
Instance Method Summary collapse
- #build(user: nil, changes: {}, action: nil) ⇒ Object
-
#initialize(issuable) ⇒ Issuable
constructor
A new instance of Issuable.
- #safe_keys ⇒ Object
Constructor Details
#initialize(issuable) ⇒ Issuable
Returns a new instance of Issuable.
10 11 12 |
# File 'lib/gitlab/data_builder/issuable.rb', line 10 def initialize(issuable) @issuable = issuable end |
Instance Attribute Details
#issuable ⇒ Object (readonly)
Returns the value of attribute issuable.
8 9 10 |
# File 'lib/gitlab/data_builder/issuable.rb', line 8 def issuable @issuable end |
Instance Method Details
#build(user: nil, changes: {}, action: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/data_builder/issuable.rb', line 14 def build(user: nil, changes: {}, action: nil) hook_data = { object_kind: object_kind, event_type: event_type, user: user.hook_attrs, project: issuable.project&.hook_attrs, object_attributes: issuable_builder.new(issuable).build, labels: issuable.labels_hook_attrs, changes: final_changes(changes.slice(*safe_keys)), # DEPRECATED repository: issuable.project&.hook_attrs&.slice(:name, :url, :description, :homepage) } hook_data[:object_attributes][:action] = action if action hook_data[:assignees] = issuable.assignees.map(&:hook_attrs) if issuable.assignees.any? if issuable.allows_reviewers? && issuable.reviewers.any? # Check if there's a re-requested reviewer in the changes re_requested_reviewer_id = extract_re_requested_reviewer_id(changes) hook_data[:reviewers] = issuable.reviewers_hook_attrs(re_requested_reviewer_id: re_requested_reviewer_id) end hook_data end |
#safe_keys ⇒ Object
39 40 41 |
# File 'lib/gitlab/data_builder/issuable.rb', line 39 def safe_keys issuable_builder.safe_hook_attributes + issuable_builder.safe_hook_relations end |