Module: MultipleTableInheritance::Parent::Base::AttributeMethods

Defined in:
lib/multiple_table_inheritance/parent/base.rb

Instance Method Summary collapse

Instance Method Details

#child_attribute_methods_generated!Object



47
48
49
# File 'lib/multiple_table_inheritance/parent/base.rb', line 47

def child_attribute_methods_generated!
  @child_attribute_methods_generated = true
end

#child_attribute_methods_generated?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/multiple_table_inheritance/parent/base.rb', line 43

def child_attribute_methods_generated?
  @child_attribute_methods_generated ||= false
end

#define_attribute_methodsObject



26
27
28
29
30
31
32
33
34
# File 'lib/multiple_table_inheritance/parent/base.rb', line 26

def define_attribute_methods
  super
  
  @child_attribute_methods_mutex.synchronize do
    return if child_attribute_methods_generated?
    extend_child_association
    child_attribute_methods_generated!
  end
end

#extend_child_associationObject



36
37
38
39
40
41
# File 'lib/multiple_table_inheritance/parent/base.rb', line 36

def extend_child_association
  if column_names.include?(subtype_column.to_s)
    include InstanceMethods
    before_destroy :destroy_child_association
  end
end