mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Not really worth having the HasAssociation module for just a single method
This commit is contained in:
committed by
Aaron Patterson
parent
770e6893b9
commit
45d0d18bae
@@ -120,7 +120,6 @@ module ActiveRecord
|
||||
# So there is no need to eager load them.
|
||||
autoload :AssociationCollection, 'active_record/associations/association_collection'
|
||||
autoload :AssociationProxy, 'active_record/associations/association_proxy'
|
||||
autoload :HasAssociation, 'active_record/associations/has_association'
|
||||
autoload :ThroughAssociation, 'active_record/associations/through_association'
|
||||
autoload :BelongsToAssociation, 'active_record/associations/belongs_to_association'
|
||||
autoload :BelongsToPolymorphicAssociation, 'active_record/associations/belongs_to_polymorphic_association'
|
||||
|
||||
@@ -18,8 +18,6 @@ module ActiveRecord
|
||||
# If you need to work on all current children, new and existing records,
|
||||
# +load_target+ and the +loaded+ flag are your friends.
|
||||
class AssociationCollection < AssociationProxy #:nodoc:
|
||||
include HasAssociation
|
||||
|
||||
delegate :group, :order, :limit, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :to => :scoped
|
||||
|
||||
def select(select = nil)
|
||||
|
||||
@@ -9,11 +9,11 @@ module ActiveRecord
|
||||
# AssociationProxy
|
||||
# BelongsToAssociation
|
||||
# BelongsToPolymorphicAssociation
|
||||
# AssociationCollection + HasAssociation
|
||||
# AssociationCollection
|
||||
# HasAndBelongsToManyAssociation
|
||||
# HasManyAssociation
|
||||
# HasManyThroughAssociation + ThroughAssociation
|
||||
# HasOneAssociation + HasAssociation
|
||||
# HasOneAssociation
|
||||
# HasOneThroughAssociation + ThroughAssociation
|
||||
#
|
||||
# Association proxies in Active Record are middlemen between the object that
|
||||
@@ -252,6 +252,13 @@ module ActiveRecord
|
||||
table.create_and(conditions)
|
||||
end
|
||||
|
||||
# Sets the owner attributes on the given record
|
||||
def set_owner_attributes(record)
|
||||
if @owner.persisted?
|
||||
construct_owner_attributes.each { |key, value| record[key] = value }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Forwards any missing method call to the \target.
|
||||
def method_missing(method, *args)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
module ActiveRecord
|
||||
module Associations
|
||||
# Included in all has_* associations (i.e. everything except belongs_to)
|
||||
module HasAssociation #:nodoc:
|
||||
protected
|
||||
# Sets the owner attributes on the given record
|
||||
def set_owner_attributes(record)
|
||||
if @owner.persisted?
|
||||
construct_owner_attributes.each { |key, value| record[key] = value }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,8 +2,6 @@ module ActiveRecord
|
||||
# = Active Record Belongs To Has One Association
|
||||
module Associations
|
||||
class HasOneAssociation < AssociationProxy #:nodoc:
|
||||
include HasAssociation
|
||||
|
||||
def create(attrs = {})
|
||||
new_record do |reflection|
|
||||
attrs = merge_with_conditions(attrs)
|
||||
|
||||
Reference in New Issue
Block a user