Module: Transfer::State::TubeState
- Included in:
- Tube
- Defined in:
- app/models/transfer/state.rb
Overview
Tube specific behaviour
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/models/transfer/state.rb', line 66 def self.included(base) 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 = [ 'LEFT OUTER JOIN `transfer_requests` transfer_requests_as_target ON transfer_requests_as_target.target_asset_id = `assets`.id' ] joins().where(transfer_requests_as_target: { state: states }) else all end } scope :without_finished_tubes, lambda { |purpose| where.not(["assets.plate_purpose_id IN (?) AND transfer_requests_as_target.state = 'passed'", purpose.map(&:id)]) } end end |