Class: Meibo::Role
- Inherits:
-
Object
- Object
- Meibo::Role
- Defined in:
- lib/meibo/role.rb
Direct Known Subclasses
Constant Summary collapse
- TYPES =
{ primary: "primary", secondary: "secondary" }.freeze
- ROLES =
{ aide: "aide", counselor: "counselor", district_administrator: "districtAdministrator", guardian: "guardian", parent: "parent", principal: "principal", proctor: "proctor", relative: "relative", site_administrator: "siteAdministrator", student: "student", system_administrator: "systemAdministrator", teacher: "teacher" }.freeze
Instance Method Summary collapse
- #aide? ⇒ Boolean
- #collection ⇒ Object
- #counselor? ⇒ Boolean
- #district_administrator? ⇒ Boolean
- #guardian? ⇒ Boolean
-
#initialize(sourced_id:, user_sourced_id:, role_type:, role:, org_sourced_id:, status: nil, date_last_modified: nil, begin_date: nil, end_date: nil, user_profile_sourced_id: nil, **extension_fields) ⇒ Role
constructor
A new instance of Role.
- #organization ⇒ Object
- #parent? ⇒ Boolean
- #primary? ⇒ Boolean
- #principal? ⇒ Boolean
- #proctor? ⇒ Boolean
- #relative? ⇒ Boolean
- #secondary? ⇒ Boolean
- #site_administrator? ⇒ Boolean
- #student? ⇒ Boolean
- #system_administrator? ⇒ Boolean
- #teacher? ⇒ Boolean
- #user ⇒ Object
- #user_profile ⇒ Object
Constructor Details
#initialize(sourced_id:, user_sourced_id:, role_type:, role:, org_sourced_id:, status: nil, date_last_modified: nil, begin_date: nil, end_date: nil, user_profile_sourced_id: nil, **extension_fields) ⇒ Role
Returns a new instance of Role.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/meibo/role.rb', line 51 def initialize(sourced_id:, user_sourced_id:, role_type:, role:, org_sourced_id:, status: nil, date_last_modified: nil, begin_date: nil, end_date: nil, user_profile_sourced_id: nil, **extension_fields) @sourced_id = sourced_id @status = status @date_last_modified = date_last_modified @user_sourced_id = user_sourced_id @role_type = role_type @role = role @begin_date = begin_date @end_date = end_date @org_sourced_id = org_sourced_id @user_profile_sourced_id = user_profile_sourced_id @extension_fields = extension_fields end |
Instance Method Details
#collection ⇒ Object
66 67 68 |
# File 'lib/meibo/role.rb', line 66 def collection Meibo.current_roster.roles end |
#counselor? ⇒ Boolean
82 83 84 |
# File 'lib/meibo/role.rb', line 82 def counselor? role == ROLES[:counselor] end |
#district_administrator? ⇒ Boolean
86 87 88 |
# File 'lib/meibo/role.rb', line 86 def district_administrator? role == ROLES[:district_administrator] end |
#guardian? ⇒ Boolean
90 91 92 |
# File 'lib/meibo/role.rb', line 90 def guardian? role == ROLES[:guardian] end |
#organization ⇒ Object
126 127 128 |
# File 'lib/meibo/role.rb', line 126 def organization Meibo.current_roster.organizations.find(org_sourced_id) end |
#parent? ⇒ Boolean
94 95 96 |
# File 'lib/meibo/role.rb', line 94 def parent? role == ROLES[:parent] end |
#primary? ⇒ Boolean
70 71 72 |
# File 'lib/meibo/role.rb', line 70 def primary? @role_type == TYPES[:primary] end |
#principal? ⇒ Boolean
98 99 100 |
# File 'lib/meibo/role.rb', line 98 def principal? role == ROLES[:principal] end |
#proctor? ⇒ Boolean
102 103 104 |
# File 'lib/meibo/role.rb', line 102 def proctor? role == ROLES[:proctor] end |
#relative? ⇒ Boolean
106 107 108 |
# File 'lib/meibo/role.rb', line 106 def relative? role == ROLES[:relative] end |
#secondary? ⇒ Boolean
74 75 76 |
# File 'lib/meibo/role.rb', line 74 def secondary? @role_type == TYPES[:secondary] end |
#site_administrator? ⇒ Boolean
110 111 112 |
# File 'lib/meibo/role.rb', line 110 def site_administrator? role == ROLES[:site_administrator] end |
#student? ⇒ Boolean
114 115 116 |
# File 'lib/meibo/role.rb', line 114 def student? role == ROLES[:student] end |
#system_administrator? ⇒ Boolean
118 119 120 |
# File 'lib/meibo/role.rb', line 118 def system_administrator? role == ROLES[:system_administrator] end |
#teacher? ⇒ Boolean
122 123 124 |
# File 'lib/meibo/role.rb', line 122 def teacher? role == ROLES[:teacher] end |
#user ⇒ Object
130 131 132 |
# File 'lib/meibo/role.rb', line 130 def user Meibo.current_roster.users.find(user_sourced_id) end |
#user_profile ⇒ Object
134 135 136 |
# File 'lib/meibo/role.rb', line 134 def user_profile user_profile_sourced_id && Meibo.current_roster.user_profiles.find(user_profile_sourced_id) end |