Class: OneRoster::Types::Teacher

Inherits:
Base
  • Object
show all
Defined in:
lib/types/teacher.rb

Direct Known Subclasses

Admin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, client: nil) ⇒ Teacher

Returns a new instance of Teacher.



13
14
15
16
17
18
19
20
21
22
# File 'lib/types/teacher.rb', line 13

def initialize(attributes = {}, *, client: nil)
  @uid          = attributes['sourcedId']
  @email        = attributes['email']
  @first_name   = attributes['givenName']
  @last_name    = attributes['familyName']
  @api_username = attributes['username']
  @username     = username(client)
  @provider     = 'oneroster'
  @role         = 'teacher'
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



6
7
8
# File 'lib/types/teacher.rb', line 6

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



6
7
8
# File 'lib/types/teacher.rb', line 6

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



6
7
8
# File 'lib/types/teacher.rb', line 6

def last_name
  @last_name
end

#providerObject (readonly)

Returns the value of attribute provider.



6
7
8
# File 'lib/types/teacher.rb', line 6

def provider
  @provider
end

#roleObject (readonly)

Returns the value of attribute role.



6
7
8
# File 'lib/types/teacher.rb', line 6

def role
  @role
end

#uidObject (readonly)

Returns the value of attribute uid.



6
7
8
# File 'lib/types/teacher.rb', line 6

def uid
  @uid
end

Instance Method Details

#to_hObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/types/teacher.rb', line 29

def to_h
  {
    uid: @uid,
    email: @email,
    first_name: @first_name,
    last_name: @last_name,
    username: @username,
    provider: @provider
  }
end

#username(client = nil) ⇒ Object



24
25
26
27
# File 'lib/types/teacher.rb', line 24

def username(client = nil)
  username_source = client&.staff_username_source
  @username ||= presence(username_from(username_source))
end