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



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

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



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

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