Module: ModelExtensions::Project

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

Overview

Included in Project The intent of this file was to provide methods specific to the V1 API

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


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

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


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

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