Class: LabClient::Membership

Inherits:
Klass show all
Includes:
AccessLevel, ClassHelpers
Defined in:
lib/labclient/users/membership.rb

Overview

Inspect Helper

Constant Summary

Constants included from AccessLevel

AccessLevel::HUMAN_ACCESS_LEVELS, AccessLevel::MACHINE_ACCESS_LEVELS

Instance Attribute Summary

Attributes inherited from Klass

#client

Attributes inherited from LabStruct

#response, #table

Instance Method Summary collapse

Methods included from AccessLevel

#human_access_level, #human_protected_access_level, #machine_access_level, #machine_protected_access_level

Methods included from ClassHelpers

#has?, #keys, #raw

Methods inherited from Klass

#api_methods, #collect_project_id, #collect_release_id, #collect_repository_id, date_time_attrs, #format_time?, #group_name, #help, #initialize, #klass, #quiet?, #success?, #to_json, #update_self, user_attrs, #valid_group_project_levels, #verbose

Methods included from Docs

#demo, #desc, #doc, docs, #example, #group_name, #help, json, #markdown, #navigation, #option, #result, #subtitle, #title

Methods included from CurlHelper

#curl

Methods included from Logger

#logger, logger, logger_setup

Methods inherited from LabStruct

#[], #[]=, #as_json, #client, #initialize, #key?, #keys, #method_missing, #respond_to_missing?, #slice, #success?, #to_h

Constructor Details

This class inherits a constructor from LabClient::Klass

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class LabClient::LabStruct

Instance Method Details

#developer?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/labclient/users/membership.rb', line 33

def developer?
  level == :developer
end

#greater_than(leveler) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/labclient/users/membership.rb', line 45

def greater_than(leveler)
  case leveler
  when Symbol
    access_level > machine_access_level(leveler)
  when Integer
    access_level > leveler
  end
end

#guest?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/labclient/users/membership.rb', line 25

def guest?
  level == :guest
end

#inspectObject



8
9
10
# File 'lib/labclient/users/membership.rb', line 8

def inspect
  "#<Membership name: #{source_name}, access: #{level}>"
end

#levelObject



21
22
23
# File 'lib/labclient/users/membership.rb', line 21

def level
  human_access_level(access_level)
end

#maintainer?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/labclient/users/membership.rb', line 37

def maintainer?
  level == :maintainer
end

#owner?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/labclient/users/membership.rb', line 41

def owner?
  level == :owner
end

#parentObject



12
13
14
15
16
17
18
19
# File 'lib/labclient/users/membership.rb', line 12

def parent
  case source_type
  when 'Project'
    client.projects.show(source_id)
  when 'Namespace'
    client.groups.show(source_id)
  end
end

#reporter?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/labclient/users/membership.rb', line 29

def reporter?
  level == :reporter
end