Class: CaTissue::SpecimenPosition

Inherits:
Object
  • Object
show all
Defined in:
lib/catissue/domain/specimen_position.rb

Instance Method Summary collapse

Instance Method Details

#saver_proxyObject

Returns a TransferEventParameters which serves as a proxy for saving this SpecimenPosition.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/catissue/domain/specimen_position.rb', line 22

def saver_proxy
  # Look for a transfer event that matches the position.
  xfr = specimen.event_parameters.detect do |sep|
    CaTissue::TransferEventParameters === sep and sep.to == location
  end
  # Create a new transfer event, if necessary.
  xfr ||= CaTissue::TransferEventParameters.new(:specimen => specimen, :to => location)
  # If this position changed, then copy the original position to the transfer event from attributes.
  if snapshot and changed? then
    xfr.from_storage_container = snapshot[:storage_container]
    xfr.from_position_dimension_one = snapshot[:position_dimension_one]
    xfr.from_position_dimension_two = snapshot[:position_dimension_two]
  end
  xfr
end