Sha256: 188298fdb8a3b6cfae5ea5eaf54ba1bbc38420da4ae5b16316dff9799f6f019b
Contents?: true
Size: 1.26 KB
Versions: 10
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require_dependency "renalware/ukrdc" require "attr_extras" require "benchmark" module Renalware module UKRDC module TreatmentTimeline class GeneratorFactory DEFAULT_TYPE = "Generic" # Returns the class of object to suitable for generating the treatment timeline for the # requested modality. If the modality description type is nil then we use a generic # generator. If no generator class is defined matching the description.type, we also # return nil. # Example: # given the modality_description.type of Renalware::Bla::BlaModalityDescription # we will look to see if the constant GenerateBlaBlaTimeline exists and return an instance # if so - otherwise we return an instance of the default generator GenerateGenericTimeline. def self.call(modality) type = modality.description.type.presence || DEFAULT_TYPE type = type.gsub("::", "").gsub(/^Renalware/, "").gsub(/ModalityDescription$/, "") (klass_for(type) || klass_for(DEFAULT_TYPE)).new(modality) end def self.klass_for(type) "Renalware::UKRDC::TreatmentTimeline::Generators::#{type}Timeline".safe_constantize end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems