Class: ApprovalGroup

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/approval_group.rb

Constant Summary collapse

FLOWS =
%w(parallel linear).freeze

Instance Method Summary collapse

Instance Method Details

#approversObject


16
17
18
# File 'app/models/approval_group.rb', line 16

def approvers
  self.users_by_role('approver')
end

#observersObject


20
21
22
# File 'app/models/approval_group.rb', line 20

def observers
  self.user_by_role('observer')
end

#requesterObject


29
30
31
# File 'app/models/approval_group.rb', line 29

def requester
  self.users_by_role('requester').first
end

#requester_idObject


24
25
26
27
# File 'app/models/approval_group.rb', line 24

def requester_id
  role = self.user_roles.where(role: 'requester').first
  role.try(:user_id)
end

#users_by_role(role) ⇒ Object


12
13
14
# File 'app/models/approval_group.rb', line 12

def users_by_role(role)
  self.users.where(user_roles: {role: role})
end