Module: Gitlab::Access

Included in:
GitPushService, Member
Defined in:
lib/gitlab/access.rb

Constant Summary collapse

GUEST =
10
REPORTER =
20
DEVELOPER =
30
MASTER =
40
OWNER =
50
PROTECTION_NONE =

Branch protection settings

0
PROTECTION_DEV_CAN_PUSH =
1
PROTECTION_FULL =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_valuesObject


24
25
26
# File 'lib/gitlab/access.rb', line 24

def all_values
  options_with_owner.values
end

.optionsObject


28
29
30
31
32
33
34
35
# File 'lib/gitlab/access.rb', line 28

def options
  {
    "Guest"     => GUEST,
    "Reporter"  => REPORTER,
    "Developer" => DEVELOPER,
    "Master"    => MASTER,
  }
end

.options_with_ownerObject


37
38
39
40
41
# File 'lib/gitlab/access.rb', line 37

def options_with_owner
  options.merge(
    "Owner" => OWNER
  )
end

.protection_optionsObject


52
53
54
55
56
57
58
# File 'lib/gitlab/access.rb', line 52

def protection_options
  {
    "Not protected: Both developers and masters can push new commits, force push, or delete the branch." => PROTECTION_NONE,
    "Partially protected: Developers can push new commits, but cannot force push or delete the branch. Masters can do all of those." => PROTECTION_DEV_CAN_PUSH,
    "Fully protected: Developers cannot push new commits, force push, or delete the branch. Only masters can do any of those." => PROTECTION_FULL,
  }
end

.protection_valuesObject


60
61
62
# File 'lib/gitlab/access.rb', line 60

def protection_values
  protection_options.values
end

.sym_optionsObject


43
44
45
46
47
48
49
50
# File 'lib/gitlab/access.rb', line 43

def sym_options
  {
    guest:     GUEST,
    reporter:  REPORTER,
    developer: DEVELOPER,
    master:    MASTER,
  }
end

.valuesObject


20
21
22
# File 'lib/gitlab/access.rb', line 20

def values
  options.values
end

Instance Method Details

#human_accessObject


65
66
67
# File 'lib/gitlab/access.rb', line 65

def human_access
  Gitlab::Access.options_with_owner.key(access_field)
end

#owner?Boolean

Returns:

  • (Boolean)

69
70
71
# File 'lib/gitlab/access.rb', line 69

def owner?
  access_field == OWNER
end