Class: Users::MergeRequestInteraction

Inherits:
Object
  • Object
show all
Defined in:
app/models/users/merge_request_interaction.rb

Instance Method Summary collapse

Constructor Details

#initialize(user:, merge_request:) ⇒ MergeRequestInteraction

Returns a new instance of MergeRequestInteraction.


5
6
7
8
# File 'app/models/users/merge_request_interaction.rb', line 5

def initialize(user:, merge_request:)
  @user = user
  @merge_request = merge_request
end

Instance Method Details

#approved?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'app/models/users/merge_request_interaction.rb', line 30

def approved?
  merge_request.approvals.any? { |app| app.user_id == user.id }
end

#can_merge?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'app/models/users/merge_request_interaction.rb', line 14

def can_merge?
  merge_request.can_be_merged_by?(user)
end

#can_update?Boolean

Returns:

  • (Boolean)

18
19
20
# File 'app/models/users/merge_request_interaction.rb', line 18

def can_update?
  user.can?(:update_merge_request, merge_request)
end

#declarative_policy_subjectObject


10
11
12
# File 'app/models/users/merge_request_interaction.rb', line 10

def declarative_policy_subject
  merge_request
end

#review_stateObject


22
23
24
# File 'app/models/users/merge_request_interaction.rb', line 22

def review_state
  reviewer&.state
end

#reviewed?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'app/models/users/merge_request_interaction.rb', line 26

def reviewed?
  reviewer&.reviewed? == true
end