Class: Limber::Helper::TemplateConstructor
- Inherits:
-
Object
- Object
- Limber::Helper::TemplateConstructor
- Includes:
- ActiveModel::Model
- Defined in:
- lib/limber/helper.rb
Overview
Construct submission templates for the Limber pipeline
Direct Known Subclasses
LibraryAndMultiplexingTemplateConstructor, LibraryOnlyTemplateConstructor
Instance Attribute Summary collapse
-
#catalogue ⇒ Object
The following are optional and change the range of submission templates constructed.
-
#cherrypicked ⇒ Object
writeonly
Sets the attribute cherrypicked.
- #name ⇒ Object
-
#pipeline ⇒ String
Prefix before submission template names.
-
#prefix ⇒ Object
The following are optional and change the range of submission templates constructed.
-
#product_line ⇒ String
The name of the ProductLine associated with the submission template.
-
#role ⇒ String
The name or the OrderRole associated with the submission template.
-
#sequencing_keys ⇒ Object
writeonly
Sets the attribute sequencing_keys.
-
#type ⇒ String
The RequestType#key of the RequestType that forms the library creation part of the generated submission templates.
Class Method Summary collapse
-
.find_for(name, sequencing = nil) ⇒ Array<SubmissionTemplate>
Finds all submission templates matching the provided name.
Instance Method Summary collapse
-
#build! ⇒ Object
Construct a series of submission templates according to the specified options.
-
#name_for(cherrypick, sequencing_request_type) ⇒ String
The name of the SubmissionTemplate for the given options.
-
#sequencing_request_types ⇒ Array
The RequestType#key of the request types that forms the sequencing part of the generated submission templates.
Instance Attribute Details
#catalogue ⇒ Object
The following are optional and change the range of submission templates constructed.
31 32 33 |
# File 'lib/limber/helper.rb', line 31 def catalogue @catalogue end |
#cherrypicked=(value) ⇒ Object (writeonly)
Sets the attribute cherrypicked
32 33 34 |
# File 'lib/limber/helper.rb', line 32 def cherrypicked=(value) @cherrypicked = value end |
#name ⇒ Object
56 57 58 |
# File 'lib/limber/helper.rb', line 56 def name @name || prefix end |
#pipeline ⇒ String
Prefix before submission template names. Defaults to PIPELINE
73 74 75 |
# File 'lib/limber/helper.rb', line 73 def pipeline @pipeline || PIPELINE end |
#prefix ⇒ Object
The following are optional and change the range of submission templates constructed.
31 32 33 |
# File 'lib/limber/helper.rb', line 31 def prefix @prefix end |
#product_line ⇒ String
The name of the ProductLine associated with the submission template.
ProductLine represents the team doing the work. Used primarily to group together submission templates for display, but is also used in downstream reporting.
If #product_line is not specified defaults to PRODUCTLINE
84 85 86 |
# File 'lib/limber/helper.rb', line 84 def product_line @product_line || PRODUCTLINE end |
#role ⇒ String
64 65 66 |
# File 'lib/limber/helper.rb', line 64 def role @role || prefix end |
#sequencing_keys=(value) ⇒ Object (writeonly)
Sets the attribute sequencing_keys
32 33 34 |
# File 'lib/limber/helper.rb', line 32 def sequencing_keys=(value) @sequencing_keys = value end |
#type ⇒ String
The RequestType#key of the RequestType that forms the library creation part of the generated submission templates.
If #type is not specified, defaults to ‘limber_’ followed by #prefix
94 95 96 |
# File 'lib/limber/helper.rb', line 94 def type @type || "limber_#{prefix.downcase.tr(' ', '_')}" end |
Class Method Details
.find_for(name, sequencing = nil) ⇒ Array<SubmissionTemplate>
Finds all submission templates matching the provided name. If sequencing is not specified will find all submission templates.
41 42 43 44 45 46 47 48 49 |
# File 'lib/limber/helper.rb', line 41 def self.find_for(name, sequencing = nil) tc = TemplateConstructor.new(name:, sequencing:) [true, false].map do |cherrypick| tc.sequencing.map do |sequencing_request_type| SubmissionTemplate.find_by!(name: tc.name_for(cherrypick, sequencing_request_type)) end end .flatten end |
Instance Method Details
#build! ⇒ Object
Construct a series of submission templates according to the specified options. ).build!
129 130 131 132 |
# File 'lib/limber/helper.rb', line 129 def build! validate! each_submission_template { |config| SubmissionTemplate.create!(config) } end |
#name_for(cherrypick, sequencing_request_type) ⇒ String
The name of the SubmissionTemplate for the given options.
114 115 116 117 118 |
# File 'lib/limber/helper.rb', line 114 def name_for(cherrypick, sequencing_request_type) "#{pipeline} - #{cherrypick ? 'Cherrypicked - ' : ''}#{name} - #{ sequencing_request_type.name.gsub(PIPELINE_REGEX, '') }" end |
#sequencing_request_types ⇒ Array
The RequestType#key of the request types that forms the sequencing part of the generated submission templates.
If sequencing_keys is not specified, defaults to ‘limber_’ followed by #prefix
104 105 106 |
# File 'lib/limber/helper.rb', line 104 def sequencing_request_types @sequencing_request_types ||= @sequencing_keys.map { |request| RequestType.find_by!(key: request) } end |