Class: RequestEvent

Inherits:
ApplicationRecord show all
Defined in:
app/models/request_event.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Class Method Details

.date_for_state(state) ⇒ Object


11
12
13
# File 'app/models/request_event.rb', line 11

def self.date_for_state(state)
  where(to_state: state).last.try(:current_from)
end

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'app/models/request_event.rb', line 21

def current?
  !current_to?
end

#expire!(date_time) ⇒ Object

Raises:

  • (StandardError)

15
16
17
18
19
# File 'app/models/request_event.rb', line 15

def expire!(date_time)
  raise StandardError, 'This event has already expired!' unless current_to.nil?

  update!(current_to: date_time)
end