aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-06 19:32:05 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-07 15:03:15 -0800
commit45d0d18baef2de739dae89bb7bc79826392bbde5 (patch)
treeb2fe8eb8c38494b29b68b988938694475d632b38 /activerecord/lib/active_record/associations
parent770e6893b9f2aaaebe3de10576931dc7194451bc (diff)
downloadrails-45d0d18baef2de739dae89bb7bc79826392bbde5.tar.gz
rails-45d0d18baef2de739dae89bb7bc79826392bbde5.tar.bz2
rails-45d0d18baef2de739dae89bb7bc79826392bbde5.zip
Not really worth having the HasAssociation module for just a single method
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb2
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb11
-rw-r--r--activerecord/lib/active_record/associations/has_association.rb14
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb2
4 files changed, 9 insertions, 20 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index f33a9ce732..daec8493ac 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -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)
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index 405a0307c1..294e1cab50 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -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)
diff --git a/activerecord/lib/active_record/associations/has_association.rb b/activerecord/lib/active_record/associations/has_association.rb
deleted file mode 100644
index 8b180c7301..0000000000
--- a/activerecord/lib/active_record/associations/has_association.rb
+++ /dev/null
@@ -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
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index 5107be1eaf..bee5700bfc 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -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)