Module: ModelExtensions::Project

Included in:
Project
Defined in:
app/api/model_extensions/project.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


2
3
4
5
6
7
# File 'app/api/model_extensions/project.rb', line 2

def self.included(base)
  base.class_eval do
    has_many :submissions
    scope :include_roles, -> { includes(roles: :users) }
  end
end

Instance Method Details

#roles_as_jsonObject


9
10
11
12
13
14
15
# File 'app/api/model_extensions/project.rb', line 9

def roles_as_json
  Hash[
    roles.map do |role|
      [role.name.underscore, role.users.map { |user| { login: user., email: user.email, name: user.name } }]
    end
  ]
end