Class: Metadata::Base
Direct Known Subclasses
CherrypickForFluidigmRequest::Metadata, LibraryCreationRequest::Metadata, Metadata, PacBioLibraryTube::Metadata, PacBioSamplePrepRequest::Metadata, PacBioSequencingRequest::Metadata, PbmcPoolingCustomerRequest::Metadata, Project::Metadata, Request::LibraryCreation::Metadata, Request::Traction::GridIon::Metadata, SequencingRequest::Metadata
Class Method Summary
collapse
Instance Method Summary
collapse
#association_value_pairs, #attribute_details_for, #attribute_value_pairs, #field_infos, included, #instance_defaults, #required?
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
extended
Constructor Details
#initialize(attributes = {}) ⇒ Base
This ensures that the default values are stored within the DB, meaning that this information will be preserved for the future, unlike the original properties information which didn’t store values when nil which lead to us having to guess.
119
120
121
|
# File 'app/models/metadata.rb', line 119
def initialize(attributes = {}, *, &)
super(self.class.defaults.merge(attributes.try(:symbolize_keys) || {}), *, &)
end
|
Class Method Details
.localised_sections(field) ⇒ Object
169
170
171
|
# File 'app/models/metadata.rb', line 169
def localised_sections(field)
localised_sections_store[field]
end
|
.localised_sections_generator(field) ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'app/models/metadata.rb', line 155
def localised_sections_generator(field)
Section.new(
*(
SECTION_FIELDS.map do |section|
I18n.t(
section,
scope: [:metadata, metadata_attribute_path(field)].flatten,
default: I18n.t(section, scope: %i[metadata defaults])
)
end << {}
)
)
end
|
.localised_sections_store ⇒ Object
151
152
153
|
# File 'app/models/metadata.rb', line 151
def localised_sections_store
@loc_sec ||= Hash.new { |h, field| h[field] = localised_sections_generator(field) }
end
|
147
148
149
|
# File 'app/models/metadata.rb', line 147
def metadata_attribute_path(field)
metadata_attribute_path_store[field]
end
|
143
144
145
|
# File 'app/models/metadata.rb', line 143
def metadata_attribute_path_generator(field)
name.underscore.split('/').map(&:to_sym) + [field.to_sym]
end
|
139
140
141
|
# File 'app/models/metadata.rb', line 139
def metadata_attribute_path_store
@md_a_p ||= Hash.new { |h, field| h[field] = metadata_attribute_path_generator(field) }
end
|
Instance Method Details
#merge_instance_defaults ⇒ Object
125
126
127
128
129
130
131
132
|
# File 'app/models/metadata.rb', line 125
def merge_instance_defaults
instance_defaults.each do |attribute, value|
next unless send(attribute).nil?
send(:"#{attribute}=", value)
end
end
|