Module: AssetLink::Associations

Included in:
Labware
Defined in:
app/models/asset_link.rb

Overview

rubocop:todo Style/Documentation

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/asset_link.rb', line 36

def self.included(base)
  base.class_eval do
    extend ClassMethods

    has_dag_links link_class_name: 'AssetLink'
    has_many :child_plates, through: :links_as_parent, source: :descendant, class_name: 'Plate'
    has_many :child_tubes, through: :links_as_parent, source: :descendant, class_name: 'Tube'
    has_many :parent_tubes, through: :links_as_child, source: :ancestor, class_name: 'Tube'
    has_many :parent_plates, through: :links_as_child, source: :ancestor, class_name: 'Plate'
  end
  base.extend(ClassMethods)
end