sanger/sequencescape

View on GitHub
app/api/model_extensions/project.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
87%
# frozen_string_literal: true
# Included in {Project}
# The intent of this file was to provide methods specific to the V1 API
module ModelExtensions::Project
  def self.included(base)
    base.class_eval do
      has_many :submissions
      scope :include_roles, -> { includes(roles: :users) }
    end
  end

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