Class: LearnGitlab

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_gitlab.rb

Constant Summary collapse

PROJECT_NAME =
'Learn GitLab'.freeze
BOARD_NAME =
'GitLab onboarding'.freeze
LABEL_NAME =
'Novice'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(current_user) ⇒ LearnGitlab

Returns a new instance of LearnGitlab.


8
9
10
# File 'lib/learn_gitlab.rb', line 8

def initialize(current_user)
  @current_user = current_user
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/learn_gitlab.rb', line 12

def available?
  project && board && label
end

#boardObject


20
21
22
23
24
# File 'lib/learn_gitlab.rb', line 20

def board
  return unless project

  @board ||= project.boards.find_by_name(BOARD_NAME)
end

#labelObject


26
27
28
29
30
# File 'lib/learn_gitlab.rb', line 26

def label
  return unless project

  @label ||= project.labels.find_by_name(LABEL_NAME)
end

#projectObject


16
17
18
# File 'lib/learn_gitlab.rb', line 16

def project
  @project ||= current_user.projects.find_by_name(PROJECT_NAME)
end