Class: Extract
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Extract
- Includes:
- Housekeeping, Shared::Identifiers, Shared::IsData, Shared::OriginRelationship, Shared::ProtocolRelationships
- Defined in:
- app/models/extract.rb
Overview
An Extract is the quantified physical entity that originated from a CollectionObject. Extracts are linked to their origin through an OriginRelationship.
Instance Attribute Summary collapse
-
#concentration_unit ⇒ Numeric
# @Merfoo, define with David.
-
#concentration_value ⇒ Numeric
# @Merfoo, define with David.
-
#day_made ⇒ Integer
2 digit day the extract originated.
-
#is_made_now ⇒ Object
Returns the value of attribute is_made_now.
-
#month_made ⇒ Integer
2 digit month the extract originated.
-
#quantity_unit ⇒ Numeric
# @Merfoo, define with David.
-
#quantity_value ⇒ Numeric
# @Merfoo, define with David.
-
#verbatim_anatomical_origin ⇒ String
Proxy for a OriginRelationship to an AnatomicalClass.
-
#year_made ⇒ Integer
4 digit year the extract originated.
Instance Method Summary collapse
- #set_made ⇒ Object protected
- #validate_units ⇒ Object protected
Methods included from Shared::IsData
#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar
Methods included from Shared::OriginRelationship
#new_objects, #old_objects, #reject_origin_relationships, #set_origin
Methods included from Shared::ProtocolRelationships
Methods included from Shared::Identifiers
#identified?, #next_by_identifier, #previous_by_identifier, #reject_identifiers
Methods included from Housekeeping
#has_polymorphic_relationship?
Methods inherited from ApplicationRecord
Instance Attribute Details
#concentration_unit ⇒ Numeric
Returns # @Merfoo, define with David.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#concentration_value ⇒ Numeric
Returns # @Merfoo, define with David.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#day_made ⇒ Integer
Returns 2 digit day the extract originated.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#is_made_now ⇒ Object
Returns the value of attribute is_made_now.
49 50 51 |
# File 'app/models/extract.rb', line 49 def is_made_now @is_made_now end |
#month_made ⇒ Integer
Returns 2 digit month the extract originated.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#quantity_unit ⇒ Numeric
Returns # @Merfoo, define with David.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#quantity_value ⇒ Numeric
Returns # @Merfoo, define with David.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#verbatim_anatomical_origin ⇒ String
Returns proxy for a OriginRelationship to an AnatomicalClass.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
#year_made ⇒ Integer
Returns 4 digit year the extract originated.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/models/extract.rb', line 36 class Extract < ApplicationRecord include Housekeeping include Shared::Identifiers include Shared::ProtocolRelationships include Shared::OriginRelationship include Shared::IsData is_origin_for 'Extract', 'Sequence' originates_from 'Extract', 'Specimen', 'Lot', 'RangedLot', 'Otu' has_many :sequences, through: :origin_relationships, source: :new_object, source_type: 'Sequence' validates_presence_of :quantity_value attr_accessor :is_made_now before_validation :set_made, if: -> {is_made_now} validates_presence_of :quantity_value validates_presence_of :quantity_unit validates :quantity_unit, with: :validate_units validates :year_made, date_year: { allow_blank: false } validates :month_made, date_month: { allow_blank: false } validates :day_made, date_day: { allow_blank: false } protected def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end end |
Instance Method Details
#set_made ⇒ Object (protected)
64 65 66 67 68 |
# File 'app/models/extract.rb', line 64 def set_made write_attribute(:year_made, Time.now.year) write_attribute(:month_made, Time.now.month) write_attribute(:day_made, Time.now.day) end |
#validate_units ⇒ Object (protected)
70 71 72 73 74 75 76 |
# File 'app/models/extract.rb', line 70 def validate_units begin RubyUnits::Unit.new(quantity_unit) rescue ArgumentError, 'Unit not recognized' errors.add(:quantity_unit, "'#{quantity_unit}' is an invalid quantity_unit") end end |