14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/multiple_table_inheritance/child/base.rb', line 14
def inherits_from(association_name, options={})
options = Base::default_options.merge(options.to_options)
inherit_methods = options.delete(:methods)
@inherited_attribute_methods_mutex = Mutex.new
extend AttributeMethods, FinderMethods
include InstanceMethods
include DelegateMethods if inherit_methods
self.parent_association_name = association_name.to_sym
self.primary_key = "#{parent_association_name}_id"
define_parent_association_builder
belongs_to parent_association_name, options
alias_method_chain parent_association_name, :autobuild
validate :parent_association_must_be_valid
before_save :parent_association_must_be_saved
end
|