Module: AssetLink::Associations

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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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