Class: Presenters::TubesWithSources::Collection

Inherits:
Object
  • Object
show all
Defined in:
app/models/presenters/tubes_with_sources.rb

Overview

Wrapper for the tube collection array

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#arrayObject (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_labelsObject



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

Returns:

  • (Boolean)


15
16
17
# File 'app/models/presenters/tubes_with_sources.rb', line 15

def tubes?
  @array.present?
end