Class: Mooset::Endpoints::Gitlab::User

Inherits:
Models::User show all
Defined in:
lib/mooset/endpoints/gitlab/user.rb

Instance Attribute Summary

Attributes inherited from Model

#endpoint

Class Method Summary collapse

Methods inherited from Models::User

#to_s

Methods inherited from Model

finders, #finders, #initialize, #to_json, #to_s

Constructor Details

This class inherits a constructor from Mooset::Model

Class Method Details

.build(endpoint, user) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mooset/endpoints/gitlab/user.rb', line 13

def self.build(endpoint, user)
  self.new(
    endpoint: endpoint,
    id: user.id,
    gitlab_id: user.id,
    username: user.username,
    full_name: user.name,
    state: user.state,
    email: user.email,
    access_level: user.access_level,
    ldap_id: Optional.new(user).identities.within do |identities|
      identity_from(Many.new(identities)).values.first
    end.value,
  )
end

.identity_from(identities) ⇒ Object



29
30
31
32
33
# File 'lib/mooset/endpoints/gitlab/user.rb', line 29

def self.identity_from(identities)
  identities.within do |o|
    o["extern_uid"] if ["ldap", "ldapmain"].include?(o["provider"])
  end
end