Class: LabwareController

Inherits:
ApplicationController show all
Defined in:
app/controllers/labware_controller.rb

Overview

Inherited by PlatesController and TubesController show => Looks up the presenter for the giver purpose and renders the appropriate show page update => Used to update the state of a plate/tube

Constant Summary collapse

UUID =
/\A[\da-f]{8}(-[\da-f]{4}){3}-[\da-f]{12}\z/

Instance Method Summary collapse

Instance Method Details

#showObject

rubocop:todo Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/labware_controller.rb', line 17

def show # rubocop:todo Metrics/AbcSize
  @presenter = presenter_for(@labware)

  response.headers['Vary'] = 'Accept'
  respond_to do |format|
    format.html { render @presenter.page }
    format.csv do
      render @presenter.csv
      response.headers['Content-Disposition'] =
        "attachment; filename=#{@presenter.filename(params['offset'])}" if @presenter.filename
    end
    format.json
  end
end

#updateObject

rubocop:todo Metrics/AbcSize



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/labware_controller.rb', line 32

def update # rubocop:todo Metrics/AbcSize
  state_changer.move_to!(*update_params)

  notice = +"Labware: #{params[:labware_barcode]} has been changed to a state of #{params[:state].titleize}."
  notice << ' The customer will still be charged.' if update_params[2]

  respond_to { |format| format.html { redirect_to(search_path, notice: notice) } }
rescue StateChangers::StateChangeError => e
  respond_to do |format|
    format.html { redirect_to(search_path, alert: e.message) }
    format.csv
  end
end