Class: Item Deprecated

Inherits:
ApplicationRecord show all
Extended by:
EventfulRecord
Includes:
EventfulRecord, Uuid::Uuidable
Defined in:
app/models/item.rb

Overview

Deprecated.

JG: As far as I am aware while these are still being generated in a few places they are no longer required and can probably be removed.

Legacy class which used to represent potential products before they had actually been created.

Constant Summary collapse

@@cached_requests =
nil

Instance Method Summary collapse

Methods included from EventfulRecord

has_many_events, has_many_lab_events, has_one_event_with_family

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#set_versionObject



35
36
37
38
39
40
41
42
# File 'app/models/item.rb', line 35

def set_version
  things_with_same_name = self.class.where(name:)
  if things_with_same_name.empty?
    increment(:version)
  else
    self.version = things_with_same_name.size + 1
  end
end