Class: ActiveRecord::Associations::Builder::HasAndBelongsToMany
- Inherits:
-
CollectionAssociation
- Object
- Association
- CollectionAssociation
- ActiveRecord::Associations::Builder::HasAndBelongsToMany
- Defined in:
- lib/active_record/associations/builder/has_and_belongs_to_many.rb
Overview
:nodoc:
Constant Summary
Constants inherited from CollectionAssociation
CollectionAssociation::CALLBACKS
Instance Attribute Summary
Attributes inherited from CollectionAssociation
#block_extension, #extension_module
Attributes inherited from Association
#model, #name, #options, #reflection, #scope
Instance Method Summary collapse
- #build ⇒ Object
- #define_destroy_hook ⇒ Object
- #macro ⇒ Object
- #show_deprecation_warnings ⇒ Object
- #valid_options ⇒ Object
Methods inherited from CollectionAssociation
#define_callback, #define_readers, #define_writers, #extension_module_name, #initialize, #wrap_block_extension, #writable?
Methods inherited from Association
build, #configure_dependency, #define_accessors, #define_readers, #define_writers, #initialize, #mixin, #valid_dependent_options, #validate_options
Constructor Details
This class inherits a constructor from ActiveRecord::Associations::Builder::CollectionAssociation
Instance Method Details
#build ⇒ Object
11 12 13 14 15 |
# File 'lib/active_record/associations/builder/has_and_belongs_to_many.rb', line 11 def build reflection = super define_destroy_hook reflection end |
#define_destroy_hook ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_record/associations/builder/has_and_belongs_to_many.rb', line 27 def define_destroy_hook name = self.name model.send(:include, Module.new { class_eval <<-RUBY, __FILE__, __LINE__ + 1 def destroy_associations association(:#{name}).delete_all super end RUBY }) end |
#macro ⇒ Object
3 4 5 |
# File 'lib/active_record/associations/builder/has_and_belongs_to_many.rb', line 3 def macro :has_and_belongs_to_many end |
#show_deprecation_warnings ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/active_record/associations/builder/has_and_belongs_to_many.rb', line 17 def show_deprecation_warnings super [:delete_sql, :insert_sql].each do |name| if .include? name ActiveSupport::Deprecation.warn("The :#{name} association option is deprecated. Please find an alternative (such as using has_many :through).") end end end |
#valid_options ⇒ Object
7 8 9 |
# File 'lib/active_record/associations/builder/has_and_belongs_to_many.rb', line 7 def super + [:join_table, :association_foreign_key, :delete_sql, :insert_sql] end |