Skip to content

Commit 45d0d18

Browse files
jonleightontenderlove
authored andcommitted
Not really worth having the HasAssociation module for just a single method
1 parent 770e689 commit 45d0d18

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

activerecord/lib/active_record/associations.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ module Associations # :nodoc:
120120
# So there is no need to eager load them.
121121
autoload :AssociationCollection, 'active_record/associations/association_collection'
122122
autoload :AssociationProxy, 'active_record/associations/association_proxy'
123-
autoload :HasAssociation, 'active_record/associations/has_association'
124123
autoload :ThroughAssociation, 'active_record/associations/through_association'
125124
autoload :BelongsToAssociation, 'active_record/associations/belongs_to_association'
126125
autoload :BelongsToPolymorphicAssociation, 'active_record/associations/belongs_to_polymorphic_association'

activerecord/lib/active_record/associations/association_collection.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ module Associations
1818
# If you need to work on all current children, new and existing records,
1919
# +load_target+ and the +loaded+ flag are your friends.
2020
class AssociationCollection < AssociationProxy #:nodoc:
21-
include HasAssociation
22-
2321
delegate :group, :order, :limit, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :to => :scoped
2422

2523
def select(select = nil)

activerecord/lib/active_record/associations/association_proxy.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ module Associations
99
# AssociationProxy
1010
# BelongsToAssociation
1111
# BelongsToPolymorphicAssociation
12-
# AssociationCollection + HasAssociation
12+
# AssociationCollection
1313
# HasAndBelongsToManyAssociation
1414
# HasManyAssociation
1515
# HasManyThroughAssociation + ThroughAssociation
16-
# HasOneAssociation + HasAssociation
16+
# HasOneAssociation
1717
# HasOneThroughAssociation + ThroughAssociation
1818
#
1919
# Association proxies in Active Record are middlemen between the object that
@@ -252,6 +252,13 @@ def construct_owner_conditions(table = aliased_table, reflection = @reflection)
252252
table.create_and(conditions)
253253
end
254254

255+
# Sets the owner attributes on the given record
256+
def set_owner_attributes(record)
257+
if @owner.persisted?
258+
construct_owner_attributes.each { |key, value| record[key] = value }
259+
end
260+
end
261+
255262
private
256263
# Forwards any missing method call to the \target.
257264
def method_missing(method, *args)

activerecord/lib/active_record/associations/has_association.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

activerecord/lib/active_record/associations/has_one_association.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module ActiveRecord
22
# = Active Record Belongs To Has One Association
33
module Associations
44
class HasOneAssociation < AssociationProxy #:nodoc:
5-
include HasAssociation
6-
75
def create(attrs = {})
86
new_record do |reflection|
97
attrs = merge_with_conditions(attrs)

0 commit comments

Comments
 (0)