Class: ActiveRecord::Associations::HasAndBelongsToManyAssociation
- Inherits:
-
AssociationCollection
- Object
- AssociationProxy
- AssociationCollection
- ActiveRecord::Associations::HasAndBelongsToManyAssociation
- Defined in:
- lib/active_record/associations/has_and_belongs_to_many_association.rb
Overview
:nodoc:
Instance Method Summary collapse
- #columns ⇒ Object
- #create(attributes = {}) ⇒ Object
- #create!(attributes = {}) ⇒ Object
- #has_primary_key? ⇒ Boolean
-
#initialize(owner, reflection) ⇒ HasAndBelongsToManyAssociation
constructor
A new instance of HasAndBelongsToManyAssociation.
- #reset_column_information ⇒ Object
Methods inherited from AssociationCollection
#<<, #any?, #build, #clear, #count, #delete, #delete_all, #destroy, #destroy_all, #empty?, #find, #first, #include?, #last, #length, #proxy_respond_to?, #replace, #reset, #size, #sum, #to_ary, #transaction, #uniq
Methods inherited from AssociationProxy
#===, #aliased_table_name, #conditions, #inspect, #loaded, #loaded?, #proxy_owner, #proxy_reflection, #proxy_respond_to?, #proxy_target, #reload, #reset, #respond_to?, #send, #target, #target=
Constructor Details
#initialize(owner, reflection) ⇒ HasAndBelongsToManyAssociation
Returns a new instance of HasAndBelongsToManyAssociation.
4 5 6 7 |
# File 'lib/active_record/associations/has_and_belongs_to_many_association.rb', line 4 def initialize(owner, reflection) super @primary_key_list = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveRecord::Associations::AssociationCollection
Instance Method Details
#columns ⇒ Object
17 18 19 |
# File 'lib/active_record/associations/has_and_belongs_to_many_association.rb', line 17 def columns @reflection.columns(@reflection.[:join_table], "#{@reflection.[:join_table]} Columns") end |
#create(attributes = {}) ⇒ Object
9 10 11 |
# File 'lib/active_record/associations/has_and_belongs_to_many_association.rb', line 9 def create(attributes = {}) create_record(attributes) { |record| insert_record(record) } end |
#create!(attributes = {}) ⇒ Object
13 14 15 |
# File 'lib/active_record/associations/has_and_belongs_to_many_association.rb', line 13 def create!(attributes = {}) create_record(attributes) { |record| insert_record(record, true) } end |
#has_primary_key? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/active_record/associations/has_and_belongs_to_many_association.rb', line 25 def has_primary_key? return @has_primary_key unless @has_primary_key.nil? @has_primary_key = (@owner.connection.supports_primary_key? && @owner.connection.primary_key(@reflection.[:join_table])) end |
#reset_column_information ⇒ Object
21 22 23 |
# File 'lib/active_record/associations/has_and_belongs_to_many_association.rb', line 21 def reset_column_information @reflection.reset_column_information end |