Created
February 20, 2020 20:51
-
-
Save qizwiz/d886f2988a890bef7e72616e22716c9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def email_task_link(task) | |
patient = task.patient | |
practice = patient.practice | |
types = %w[sm_dso_doctor_setup_review_approve_order_aligner | |
assign_clinical_advisor | |
select_package_type] | |
options = [ | |
{ link: 'task_setup_review_url', args: %i[practice task] }, | |
{ link: 'edit_practice_patient_url', args: %i[practice task] }, | |
{ link: 'new_order_url', args: %i[practice patient] } | |
] | |
kinds = [types, options].transpose.to_h | |
kind = task.kind | |
if types.include?(kind) | |
index = kinds[kind] | |
mapped_args = index[:args].map { |arg| binding.local_variable_get arg } | |
send index[:link].to_sym, *mapped_args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment