Module: AssetLink::Associations

Defined in:
app/models/asset_link.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/models/asset_link.rb', line 47

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