Class: Mooset::Endpoints::Gitlab::UserSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/mooset/endpoints/gitlab/user_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ UserSearch

Returns a new instance of UserSearch.



7
8
9
# File 'lib/mooset/endpoints/gitlab/user_search.rb', line 7

def initialize(endpoint)
  @endpoint = endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



5
6
7
# File 'lib/mooset/endpoints/gitlab/user_search.rb', line 5

def endpoint
  @endpoint
end

Instance Method Details

#allObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mooset/endpoints/gitlab/user_search.rb', line 11

def all
  page = 1
  objects = []

  while (o = connection.users(page: page)).length > 0 do
    objects += o
    page += 1
  end

  objects.collect do |object|
    User.build(endpoint.endpoint_name, object)
  end
end

#find(id) ⇒ Object



25
26
27
# File 'lib/mooset/endpoints/gitlab/user_search.rb', line 25

def find(id)
  User.build(endpoint.endpoint_name, connection.user(id))
end

#memberof(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mooset/endpoints/gitlab/user_search.rb', line 29

def memberof(id)
  page = 1
  objects = []

  while (o = connection.group_members(id, page: page)).length > 0 do
    objects += o
    page += 1
  end

  objects.collect do |object|
    User.build(endpoint.endpoint_name, object)
  end
end