Class: Gitlab::DataBuilder::Issuable

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/data_builder/issuable.rb

Constant Summary collapse

CHANGES_KEYS =
%i[previous current].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#issuableObject (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: {}) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/data_builder/issuable.rb', line 14

def build(user: nil, changes: {})
  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[:assignees] = issuable.assignees.map(&:hook_attrs) if issuable.assignees.any?

  hook_data
end

#safe_keysObject


32
33
34
# File 'lib/gitlab/data_builder/issuable.rb', line 32

def safe_keys
  issuable_builder.safe_hook_attributes + issuable_builder.safe_hook_relations
end