Class: Meibo::User
- Inherits:
-
Object
- Object
- Meibo::User
- Defined in:
- lib/meibo/user.rb
Direct Known Subclasses
Constant Summary collapse
- USER_ID_FORMAT_REGEXP =
/\A\{[^:}]+:[^}]+\}\z/.freeze
Instance Method Summary collapse
- #agents ⇒ Object
- #collection ⇒ Object
- #demographic ⇒ Object
- #enrollments ⇒ Object
-
#initialize(sourced_id:, username:, given_name:, family_name:, status: nil, date_last_modified: nil, enabled_user: nil, user_ids: nil, middle_name: nil, identifier: nil, email: nil, sms: nil, phone: nil, agent_sourced_ids: [], grades: nil, password: nil, user_master_identifier: nil, preferred_given_name: nil, preferred_middle_name: nil, preferred_family_name: nil, primary_org_sourced_id: nil, pronouns: nil, **extension_fields) ⇒ User
constructor
A new instance of User.
- #primary_organization ⇒ Object
- #primary_role_in(org) ⇒ Object
- #roles ⇒ Object
- #user_profiles ⇒ Object
Constructor Details
#initialize(sourced_id:, username:, given_name:, family_name:, status: nil, date_last_modified: nil, enabled_user: nil, user_ids: nil, middle_name: nil, identifier: nil, email: nil, sms: nil, phone: nil, agent_sourced_ids: [], grades: nil, password: nil, user_master_identifier: nil, preferred_given_name: nil, preferred_middle_name: nil, preferred_family_name: nil, primary_org_sourced_id: nil, pronouns: nil, **extension_fields) ⇒ User
Returns a new instance of User.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/meibo/user.rb', line 43 def initialize(sourced_id:, username:, given_name:, family_name:, status: nil, date_last_modified: nil, enabled_user: nil, user_ids: nil, middle_name: nil, identifier: nil, email: nil, sms: nil, phone: nil, agent_sourced_ids: [], grades: nil, password: nil, user_master_identifier: nil, preferred_given_name: nil, preferred_middle_name: nil, preferred_family_name: nil, primary_org_sourced_id: nil, pronouns: nil, **extension_fields) @sourced_id = sourced_id @status = status @date_last_modified = date_last_modified @enabled_user = enabled_user @username = username @user_ids = user_ids @given_name = given_name @family_name = family_name @middle_name = middle_name @identifier = identifier @email = email @sms = sms @phone = phone @agent_sourced_ids = agent_sourced_ids @grades = grades @password = password @user_master_identifier = user_master_identifier @preferred_given_name = preferred_given_name @preferred_middle_name = preferred_middle_name @preferred_family_name = preferred_family_name @primary_org_sourced_id = primary_org_sourced_id @pronouns = pronouns @extension_fields = extension_fields end |
Instance Method Details
#agents ⇒ Object
74 75 76 |
# File 'lib/meibo/user.rb', line 74 def agents agent_sourced_ids.map { |agent_sourced_id| Meibo.current_roster.users.find(agent_sourced_id) } end |
#collection ⇒ Object
70 71 72 |
# File 'lib/meibo/user.rb', line 70 def collection Meibo.current_roster.users end |
#demographic ⇒ Object
78 79 80 81 82 |
# File 'lib/meibo/user.rb', line 78 def demographic Meibo.current_roster.demographics.find(sourced_id) rescue DataNotFoundError nil end |
#enrollments ⇒ Object
84 85 86 |
# File 'lib/meibo/user.rb', line 84 def enrollments Meibo.current_roster.enrollments.where(user_sourced_id: sourced_id) end |
#primary_organization ⇒ Object
88 89 90 |
# File 'lib/meibo/user.rb', line 88 def primary_organization primary_org_sourced_id && Meibo.current_roster.organizations.find(primary_org_sourced_id) end |
#primary_role_in(org) ⇒ Object
92 93 94 95 96 |
# File 'lib/meibo/user.rb', line 92 def primary_role_in(org) Meibo.current_roster.roles.where(user_sourced_id: sourced_id).detect do |role| role.primary? && role.org_sourced_id == org.sourced_id end end |
#roles ⇒ Object
98 99 100 |
# File 'lib/meibo/user.rb', line 98 def roles Meibo.current_roster.roles.where(user_sourced_id: sourced_id) end |
#user_profiles ⇒ Object
102 103 104 |
# File 'lib/meibo/user.rb', line 102 def user_profiles Meibo.current_roster.user_profiles.where(user_sourced_id: sourced_id) end |