Module: AbilityHost::CourseHelpers

Defined in:
app/models/components/ability_host.rb

Overview

Helpers for defining abilities associated with a course user.

Instance Method Summary collapse

Instance Method Details

#course_course_user_hash(*roles) ⇒ Hash (protected) Also known as: course_all_course_users_hash


37
38
39
# File 'app/models/components/ability_host.rb', line 37

def course_course_user_hash(*roles)
  { course: course_user_hash(*roles) }
end

#course_managers_hashHash (protected)


54
55
56
# File 'app/models/components/ability_host.rb', line 54

def course_managers_hash
  course_course_user_hash(*CourseUser::MANAGER_ROLES.to_a)
end

#course_staff_hashHash (protected)


44
45
46
# File 'app/models/components/ability_host.rb', line 44

def course_staff_hash
  course_course_user_hash(*CourseUser::STAFF_ROLES.to_a)
end

#course_teaching_staff_hashHash (protected)


49
50
51
# File 'app/models/components/ability_host.rb', line 49

def course_teaching_staff_hash
  course_course_user_hash(*CourseUser::TEACHING_STAFF_ROLES.to_a)
end

#course_user_hash(*roles) ⇒ Hash (protected)

Creates a hash which allows referencing a set of course users.


14
15
16
17
18
19
# File 'app/models/components/ability_host.rb', line 14

def course_user_hash(*roles)
  course_users = { user_id: user.id }
  course_users[:role] = roles.map { |role| CourseUser.roles[role] } unless roles.empty?

  { course_users: course_users }
end

#managers_hashHash (protected)


32
33
34
# File 'app/models/components/ability_host.rb', line 32

def managers_hash
  course_user_hash(*CourseUser::MANAGER_ROLES.to_a)
end

#staff_hashHash (protected)


22
23
24
# File 'app/models/components/ability_host.rb', line 22

def staff_hash
  course_user_hash(*CourseUser::STAFF_ROLES.to_a)
end

#teaching_staff_hashHash (protected)


27
28
29
# File 'app/models/components/ability_host.rb', line 27

def teaching_staff_hash
  course_user_hash(*CourseUser::TEACHING_STAFF_ROLES.to_a)
end