Class: Reception::LibraryTypeHelper

Inherits:
Object
  • Object
show all
Defined in:
app/models/reception/resource_factory.rb

Overview

A helper that deals with the creation of library type specific records.

Instance Method Summary collapse

Constructor Details

#initialize(library_type, resource_factory, container_attributes) ⇒ LibraryTypeHelper

Returns a new instance of LibraryTypeHelper.



183
184
185
186
187
# File 'app/models/reception/resource_factory.rb', line 183

def initialize(library_type, resource_factory, container_attributes)
  @library_type = library_type
  @resource_factory = resource_factory
  @container_attributes = container_attributes
end

Instance Method Details

#create_library(request) ⇒ Object



189
190
191
192
193
194
# File 'app/models/reception/resource_factory.rb', line 189

def create_library(request)
  # The library type is used to help build the correct library in the correct pipeline
  return unless @container_attributes[:library]

  @library_type.library_factory(request:, library_attributes: @container_attributes[:library])
end

#create_request(sample, container, reception) ⇒ Object



196
197
198
199
200
201
202
203
204
205
# File 'app/models/reception/resource_factory.rb', line 196

def create_request(sample, container, reception)
  # The library type is used to help build the correct request in the correct pipeline
  @library_type.request_factory(
    sample:,
    container:,
    request_attributes: @container_attributes[:request],
    resource_factory: @resource_factory,
    reception:
  )
end