Class: RequestEvent

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

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 Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Class Method Details

.date_for_state(state) ⇒ Object


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

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

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)

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

def current?
  !current_to?
end

#expire!(date_time) ⇒ Object

Raises:

  • (StandardError)

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

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

  update!(current_to: date_time)
end