Class: Extract

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::Identifiable, Shared::IsData, Shared::OriginRelationship
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)

Instance Method Summary (collapse)

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Instance Attribute Details

- (Numeric) concentration_unit

Returns # @Merfoo, define with David

Returns:

  • (Numeric)

    # @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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Numeric) concentration_value

Returns # @Merfoo, define with David

Returns:

  • (Numeric)

    # @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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Integer) day_made

Returns 2 digit day the extract originated

Returns:

  • (Integer)

    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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Object) is_made_now

Returns the value of attribute is_made_now



45
46
47
# File 'app/models/extract.rb', line 45

def is_made_now
  @is_made_now
end

- (Integer) month_made

Returns 2 digit month the extract originated

Returns:

  • (Integer)

    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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Numeric) quantity_unit

Returns # @Merfoo, define with David

Returns:

  • (Numeric)

    # @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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Numeric) quantity_value

Returns # @Merfoo, define with David

Returns:

  • (Numeric)

    # @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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (String) verbatim_anatomical_origin

Returns proxy for a OriginRelationship to an AnatomicalClass

Returns:

  • (String)

    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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Integer) year_made

Returns 4 digit year the extract originated

Returns:

  • (Integer)

    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
# File 'app/models/extract.rb', line 36

class Extract < ApplicationRecord
  include Housekeeping
  include Shared::IsData
  include Shared::Identifiable
  include Shared::OriginRelationship

  is_origin_for 'Sequence', 'Extract'

  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

- (Object) set_made (protected)



60
61
62
63
64
# File 'app/models/extract.rb', line 60

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

- (Object) validate_units (protected)



66
67
68
69
70
71
72
# File 'app/models/extract.rb', line 66

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