Class: PickList::RecordCache
- Inherits:
-
Object
- Object
- PickList::RecordCache
- Defined in:
- app/models/pick_list/record_cache.rb
Overview
The record cache collects all ids used in the request and optimizes the lookup into a single query, with appropriate eager loading. Built for use with Api::V2::PickListResource
Direct Known Subclasses
Defined Under Namespace
Classes: ByLabware, ByReceptacle
Constant Summary collapse
- RECEPTACLE_KEYS =
%i[source_receptacle_id study_id project_id].freeze
- LABWARE_KEYS =
%i[source_labware_id source_labware_barcode study_id project_id].freeze
Instance Method Summary collapse
- #add(entry) ⇒ Object
-
#initialize(picks) ⇒ RecordCache
constructor
Create a new cache.
Constructor Details
#initialize(picks) ⇒ RecordCache
Create a new cache
91 92 93 94 |
# File 'app/models/pick_list/record_cache.rb', line 91 def initialize(picks) @store = Hash.new { |hash, key| hash[key] = Set.new } picks.each { |pick| add(pick) } end |
Instance Method Details
#add(entry) ⇒ Object
96 97 98 |
# File 'app/models/pick_list/record_cache.rb', line 96 def add(entry) self.class::KEYS.each { |key| @store[key] << entry[key] } end |