Class VocabularyListsUser
In: app/models/vocabulary_lists_user.rb
Parent: ActiveRecord::Base

Methods

Public Class methods

[Source]

    # File app/models/vocabulary_lists_user.rb, line 20
20:   def self.create_editor vocabulary_list, user
21:     vocabulary_lists_user                 = VocabularyListsUser.new
22:     vocabulary_lists_user.vocabulary_list = vocabulary_list
23:     vocabulary_lists_user.user            = user
24:     vocabulary_lists_user.vocabulary_role = VocabularyRole.get_editor
25:     return vocabulary_lists_user
26:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 12
12:   def self.create_owner vocabulary_list, user
13:     vocabulary_lists_user                 = VocabularyListsUser.new
14:     vocabulary_lists_user.vocabulary_list = vocabulary_list
15:     vocabulary_lists_user.user            = user
16:     vocabulary_lists_user.vocabulary_role = VocabularyRole.get_owner
17:     return vocabulary_lists_user
18:   end

Public Instance methods

[Source]

    # File app/models/vocabulary_lists_user.rb, line 28
28:   def authorized_for_edit?(user)
29:     self.user == user
30:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 36
36:   def is_editor?(user)
37:     self.user == user && self.vocabulary_role == VocabularyRole.get_editor
38:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 32
32:   def is_owner?(user)
33:     self.user == user && self.vocabulary_role == VocabularyRole.get_owner
34:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 8
 8:   def to_label
 9:     "#{user.to_label} (#{vocabulary_role.role})"
10:   end

Protected Instance methods

[Source]

    # File app/models/vocabulary_lists_user.rb, line 42
42:   def authorized_for_create?
43:     return Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_USER)
44:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 50
50:   def authorized_for_destroy?
51:     return (self.vocabulary_role && self.vocabulary_role.users && self.vocabulary_role.users.include?(current_user)) || Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_ADMIN)
52:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 54
54:   def authorized_for_read?
55:     return Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_USER)
56:   end

[Source]

    # File app/models/vocabulary_lists_user.rb, line 46
46:   def authorized_for_update?
47:     return (self.vocabulary_role && self.vocabulary_role.users && self.vocabulary_role.users.include?(current_user)) || Authorize.is_role_allowed_for_user?(current_user, UserRole::USER_ROLE_ADMIN)
48:   end

[Validate]