Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (34 sloc) 0.967 kb
52f8e4b @jonleighton Use proper objects to do the work to build the associations (adding meth...
jonleighton authored
1 module ActiveRecord::Associations::Builder
2 class HasAndBelongsToMany < CollectionAssociation #:nodoc:
09d2f16 @jonleighton stop using class_attribute where methods/inheritance will suffice.
jonleighton authored
3 def macro
4 :has_and_belongs_to_many
5 end
52f8e4b @jonleighton Use proper objects to do the work to build the associations (adding meth...
jonleighton authored
6
09d2f16 @jonleighton stop using class_attribute where methods/inheritance will suffice.
jonleighton authored
7 def valid_options
7f3b475 @jonleighton Revert "Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql."
jonleighton authored
8 super + [:join_table, :association_foreign_key, :delete_sql, :insert_sql]
09d2f16 @jonleighton stop using class_attribute where methods/inheritance will suffice.
jonleighton authored
9 end
52f8e4b @jonleighton Use proper objects to do the work to build the associations (adding meth...
jonleighton authored
10
11 def build
12 reflection = super
ea4b94a Destroy association habtm record before destroying the record itself. Fi...
Tomas D'Stefano authored
13 define_destroy_hook
52f8e4b @jonleighton Use proper objects to do the work to build the associations (adding meth...
jonleighton authored
14 reflection
15 end
16
4efebde @jonleighton Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.
jonleighton authored
17 def show_deprecation_warnings
18 super
19
20 [:delete_sql, :insert_sql].each do |name|
21 if options.include? name
22 ActiveSupport::Deprecation.warn("The :#{name} association option is deprecated. Please find an alternative (such as using has_many :through).")
23 end
24 end
25 end
26
825c05d @jonleighton Unprivatise all the things
jonleighton authored
27 def define_destroy_hook
28 name = self.name
29 model.send(:include, Module.new {
30 class_eval <<-RUBY, __FILE__, __LINE__ + 1
31 def destroy_associations
6e57d5c @jonleighton Use method compilation for association methods
jonleighton authored
32 association(:#{name}).delete_all
825c05d @jonleighton Unprivatise all the things
jonleighton authored
33 super
34 end
35 RUBY
36 })
37 end
52f8e4b @jonleighton Use proper objects to do the work to build the associations (adding meth...
jonleighton authored
38 end
39 end
Something went wrong with that request. Please try again.