Skip to content

Instantly share code, notes, and snippets.

@qizwiz
Created February 20, 2020 20:51
Show Gist options
  • Save qizwiz/d886f2988a890bef7e72616e22716c9c to your computer and use it in GitHub Desktop.
Save qizwiz/d886f2988a890bef7e72616e22716c9c to your computer and use it in GitHub Desktop.
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