Class: Presenters::TubesWithSources::Collection
- Inherits:
-
Object
- Object
- Presenters::TubesWithSources::Collection
- Defined in:
- app/models/presenters/tubes_with_sources.rb
Overview
Wrapper for the tube collection array
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
Instance Method Summary collapse
-
#initialize(array) ⇒ Collection
constructor
A new instance of Collection.
- #tube_labels ⇒ Object
- #tubes? ⇒ Boolean
Constructor Details
#initialize(array) ⇒ Collection
Returns a new instance of Collection.
11 12 13 |
# File 'app/models/presenters/tubes_with_sources.rb', line 11 def initialize(array) @array = array end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
9 10 11 |
# File 'app/models/presenters/tubes_with_sources.rb', line 9 def array @array end |
Instance Method Details
#tube_labels ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/presenters/tubes_with_sources.rb', line 19 def tube_labels # Optimization: To avoid needing to load in the tube aliquots, we use the transfers into the # tube to work out the pool size. This information is already available. Two values are different # for ISC though. TODO: MUST RE-JIG # Tubes might have different labels in purpose config. Load the right labels to avoid different behaviour. @array.map do |tube| config = Settings.purposes.fetch(tube.purpose&.uuid, {}) label_class = config.fetch(:label_class, 'Labels::TubeLabel') label_class.constantize.new(tube, pool_size: tube.pool_size) end end |
#tubes? ⇒ Boolean
15 16 17 |
# File 'app/models/presenters/tubes_with_sources.rb', line 15 def tubes? @array.present? end |