Class: ProjectMember

Inherits:
ApplicationRecord show all
Includes:
Housekeeping::Timestamps, Housekeeping::Users, Shared::IsData
Defined in:
app/models/project_member.rb

Overview

A ProjectMember is the link between projects and users.

Instance Attribute Summary collapse

Attributes included from Housekeeping::Users

#by

Instance Method Summary collapse

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Housekeeping::Users

#set_created_by_id, #set_updated_by_id

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#is_project_administratorBoolean

Returns whether the user is a project administrator.

Returns:

  • (Boolean)

    whether the user is a project administrator



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/project_member.rb', line 15

class ProjectMember < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData

  belongs_to :project, inverse_of: :project_members
  belongs_to :user, inverse_of: :project_members

  validates :project, presence: true
  validates :user, presence: true
  validates_uniqueness_of :user_id, scope: [:project_id], message: 'is already a member of project'
  validate :clipboard_slots

  protected

  def clipboard_slots
    errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
  end

end

#project_idInteger

the project ID

Returns:

  • (Integer)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/project_member.rb', line 15

class ProjectMember < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData

  belongs_to :project, inverse_of: :project_members
  belongs_to :user, inverse_of: :project_members

  validates :project, presence: true
  validates :user, presence: true
  validates_uniqueness_of :user_id, scope: [:project_id], message: 'is already a member of project'
  validate :clipboard_slots

  protected

  def clipboard_slots
    errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
  end

end

#user_idInteger

Returns the user.

Returns:

  • (Integer)

    the user



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/project_member.rb', line 15

class ProjectMember < ApplicationRecord
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData

  belongs_to :project, inverse_of: :project_members
  belongs_to :user, inverse_of: :project_members

  validates :project, presence: true
  validates :user, presence: true
  validates_uniqueness_of :user_id, scope: [:project_id], message: 'is already a member of project'
  validate :clipboard_slots

  protected

  def clipboard_slots
    errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
  end

end

Instance Method Details

#clipboard_slotsObject (protected)



30
31
32
# File 'app/models/project_member.rb', line 30

def clipboard_slots
  errors.add(:clipboard, 'slot is not legal') if clipboard.keys - %w{1 2 3 4 5} != []
end