Class: PickList::RecordCache::ByReceptacle
- Inherits:
-
PickList::RecordCache
- Object
- PickList::RecordCache
- PickList::RecordCache::ByReceptacle
- Defined in:
- app/models/pick_list/record_cache.rb
Overview
Pick-list cache where the source_receptacles are indicated directly via source_receptacle_id:
Constant Summary collapse
- KEYS =
%i[source_receptacle_id study_id project_id].freeze
Constants inherited from PickList::RecordCache
Instance Method Summary collapse
Methods inherited from PickList::RecordCache
Constructor Details
This class inherits a constructor from PickList::RecordCache
Instance Method Details
#convert(entry) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/pick_list/record_cache.rb', line 14 def convert(entry) source_receptacle_id, study_id, project_id = entry.values_at(:source_receptacle_id, :study_id, :project_id) entry .except(*RECEPTACLE_KEYS) .to_hash .merge( source_receptacle: source_receptacle(source_receptacle_id), study: study(study_id), project: project(project_id) ) end |
#source_receptacle(id) ⇒ Object
26 27 28 29 |
# File 'app/models/pick_list/record_cache.rb', line 26 def source_receptacle(id) @source_receptacle ||= Receptacle.includes(:studies, :projects).find(stored(:source_receptacle_id)).index_by(&:id) @source_receptacle[id] || missing_resource('receptacle ids', id) end |