lib/meibo/user.rb in meibo-0.16.0 vs lib/meibo/user.rb in meibo-0.17.0
- old
+ new
@@ -1,49 +1,50 @@
# frozen_string_literal: true
module Meibo
class User
- USER_ID_FORMAT_REGEXP = /\A\{[^:\}]+:[^\}]+\}\z/
+ USER_ID_FORMAT_REGEXP = /\A\{[^:}]+:[^}]+\}\z/.freeze
DataModel.define(
self,
attribute_name_to_header_field_map: {
- sourced_id: 'sourcedId',
- status: 'status',
- date_last_modified: 'dateLastModified',
- enabled_user: 'enabledUser',
- username: 'username',
- user_ids: 'userIds',
- given_name: 'givenName',
- family_name: 'familyName',
- middle_name: 'middleName',
- identifier: 'identifier',
- email: 'email',
- sms: 'sms',
- phone: 'phone',
- agent_sourced_ids: 'agentSourcedIds',
- grades: 'grades',
- password: 'password',
- user_master_identifier: 'userMasterIdentifier',
- resource_sourced_ids: 'resourceSourcedIds',
- preferred_given_name: 'preferredGivenName',
- preferred_middle_name: 'preferredMiddleName',
- preferred_family_name: 'preferredFamilyName',
- primary_org_sourced_id: 'primaryOrgSourcedId',
- pronouns: 'pronouns'
+ sourced_id: "sourcedId",
+ status: "status",
+ date_last_modified: "dateLastModified",
+ enabled_user: "enabledUser",
+ username: "username",
+ user_ids: "userIds",
+ given_name: "givenName",
+ family_name: "familyName",
+ middle_name: "middleName",
+ identifier: "identifier",
+ email: "email",
+ sms: "sms",
+ phone: "phone",
+ agent_sourced_ids: "agentSourcedIds",
+ grades: "grades",
+ password: "password",
+ user_master_identifier: "userMasterIdentifier",
+ resource_sourced_ids: "resourceSourcedIds",
+ preferred_given_name: "preferredGivenName",
+ preferred_middle_name: "preferredMiddleName",
+ preferred_family_name: "preferredFamilyName",
+ primary_org_sourced_id: "primaryOrgSourcedId",
+ pronouns: "pronouns"
}.freeze,
converters: {
boolean: [:enabled_user].freeze,
datetime: [:date_last_modified].freeze,
- list: [:user_ids, :agent_sourced_ids, :grades, :resource_sourced_ids].freeze,
- required: [:sourced_id, :enabled_user, :username, :given_name, :family_name].freeze,
+ list: %i[user_ids agent_sourced_ids grades resource_sourced_ids].freeze,
+ required: %i[sourced_id enabled_user username given_name family_name].freeze,
status: [:status].freeze,
user_ids: [:user_ids].freeze
}.freeze
)
- def initialize(sourced_id:, status: nil, date_last_modified: nil, enabled_user: nil, username:, user_ids: nil, given_name:, family_name:, middle_name: nil, identifier: nil, email: nil, sms: nil, phone: nil, agent_sourced_ids: [], grades: nil, password: nil, user_master_identifier: nil, resource_sourced_ids: nil, preferred_given_name: nil, preferred_middle_name: nil, preferred_family_name: nil, primary_org_sourced_id: nil, pronouns: nil, **extension_fields)
+ 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, resource_sourced_ids: 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
@@ -71,10 +72,10 @@
def collection
Meibo.current_roster.users
end
def agents
- agent_sourced_ids.map {|agent_sourced_id| Meibo.current_roster.users.find(agent_sourced_id) }
+ agent_sourced_ids.map { |agent_sourced_id| Meibo.current_roster.users.find(agent_sourced_id) }
end
def demographic
Meibo.current_roster.demographics.find(sourced_id)
rescue DataNotFoundError