Module: Transfer::State::PlateState
- Included in:
- Plate
- Defined in:
- app/models/transfer/state.rb
Overview
Plate specific behaviour
Class Method Summary collapse
-
.included(base) ⇒ Object
rubocop:todo Metrics/MethodLength.
Class Method Details
.included(base) ⇒ Object
rubocop:todo Metrics/MethodLength
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/transfer/state.rb', line 35 def self.included(base) # rubocop:todo Metrics/MethodLength base.class_eval do scope :in_state, lambda { |states| states = Array(states).map(&:to_s) # If all of the states are present there is no point in actually adding this set of conditions because # we're basically looking for all of the plates. if states.sort != ALL_STATES.sort # Note that 'state IS NULL' is included here for plates that are stock plates, because they will not # have any transfer requests coming into their wells and so we can assume they are pending (from the # perspective of pulldown at least). query_conditions = +'transfer_requests.state IN (?)' if states.include?('pending') query_conditions << ' OR (transfer_requests.state IS NULL AND plate_purposes.stock_plate=TRUE)' end joins(:transfer_requests_as_target, :plate_purpose).where([query_conditions, states]) else all end } end end |