Class: Aliquot

Inherits:
ActiveRecordShared show all
Defined in:
app/models/aliquot.rb

Overview

requires

* sample_id * unit_id * owner_id

Instance Method Summary collapse

Instance Method Details

#transfer_to(organization) ⇒ Object

Create a #Transfer for the given #Aliquot from the current owner(#Organization) to the given #Organization.



21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/aliquot.rb', line 21

def transfer_to(organization)
  org = Organization.find(organization)
  #  I don't think that the transaction is necessary
  #  but I also don't think that it will hurt.
  Aliquot.transaction do
    # wrap this in a transaction because
    # we don't want the aliquot.owner being
    # out of sync with the last transfer.to
    self.transfer.to(org).save!
  end
end