Class: Clever::Types::Teacher
Direct Known Subclasses
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(attributes = {}, client: nil) ⇒ Teacher
constructor
A new instance of Teacher.
- #to_h ⇒ Object
- #username(client = nil) ⇒ Object
Constructor Details
#initialize(attributes = {}, client: nil) ⇒ Teacher
Returns a new instance of Teacher.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/clever/types/teacher.rb', line 13 def initialize(attributes = {}, *, client: nil) @district_username = attributes.dig('roles', 'teacher', 'credentials', 'district_username') @email = attributes['email'] @first_name = attributes['name']['first'] @last_name = attributes['name']['last'] @provider = 'clever' @sis_id = attributes.dig('roles', 'teacher', 'sis_id') @uid = attributes['id'] @username = username(client) @role = 'teacher' end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
6 7 8 |
# File 'lib/clever/types/teacher.rb', line 6 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
6 7 8 |
# File 'lib/clever/types/teacher.rb', line 6 def first_name @first_name end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
6 7 8 |
# File 'lib/clever/types/teacher.rb', line 6 def last_name @last_name end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
6 7 8 |
# File 'lib/clever/types/teacher.rb', line 6 def provider @provider end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
6 7 8 |
# File 'lib/clever/types/teacher.rb', line 6 def role @role end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
6 7 8 |
# File 'lib/clever/types/teacher.rb', line 6 def uid @uid end |
Instance Method Details
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/clever/types/teacher.rb', line 38 def to_h { uid: @uid, email: @email, first_name: @first_name, last_name: @last_name, username: @username, provider: @provider } end |
#username(client = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/clever/types/teacher.rb', line 25 def username(client = nil) return @username if defined?(@username) username_source = client&.staff_username_source username = presence(username_from(username_source)) if client&.staffer_username_search_for username = username&.gsub(client.staffer_username_search_for, client.staffer_username_replace_with || '') end @username = username end |