Class: Aker::Material

Inherits:
Mapping show all
Defined in:
app/models/aker/material.rb

Overview

Provides access to the information for an Aker Biomaterial that is spread into different Sequencescape tables. This class allows to read and update the data to keep in sync Aker and Sequencescape copy of the sample

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mapping

#_each_model_and_setting_attrs_for, #attribute_names_for_column, #config, #get_value_for, #mapped_setting_attributes_for_table, #table_names_for_attr, #table_names_to_update, #update, #update!, #update_model

Constructor Details

#initialize(instance) ⇒ Material


14
15
16
# File 'app/models/aker/material.rb', line 14

def initialize(instance)
  @instance = instance
end

Instance Attribute Details

#instanceObject Also known as: sample

Returns the value of attribute instance


7
8
9
# File 'app/models/aker/material.rb', line 7

def instance
  @instance
end

Class Method Details

.configObject


19
20
21
22
# File 'app/models/aker/material.rb', line 19

def config
  Aker::Material.config = Rails.configuration.aker[:material_mapping] if @config.nil?
  @config
end

Instance Method Details

#attributesObject

Defines the attributes that will be sent back to Aker


26
27
28
29
30
# File 'app/models/aker/material.rb', line 26

def attributes
  attrs = super
  attrs[:_id] = sample.uuid
  attrs
end

#columns_for_table_from_field(table_name, field_name) ⇒ Object


42
43
44
45
46
47
# File 'app/models/aker/material.rb', line 42

def columns_for_table_from_field(table_name, field_name)
  return field_name unless sample

  table_name = :sample if container && !container.a_well? && (table_name == :well_attribute)
  super(table_name, field_name)
end

#model_for_table(table_name) ⇒ Object

Defines the table related with a model in the config provided


33
34
35
36
37
38
39
40
# File 'app/models/aker/material.rb', line 33

def model_for_table(table_name)
  return sample if table_name == :sample
  return sample. if table_name == :sample_metadata
  return sample.container.asset.well_attribute if table_name == :well_attribute && sample && sample.container && sample.container.a_well?
  return sample.container.asset if table_name == :well_attribute && sample && sample.container && !sample.container.a_well?

  nil
end