aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-31 17:35:43 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-31 17:35:43 -0700
commitc856d895bd054d0c474f1a3876257400db529590 (patch)
tree1fbcd91414ad1928348a5beaa50c8f7f26f58f10
parentbc06ee374b953a985e045370cbb260cda59b7130 (diff)
downloadrails-c856d895bd054d0c474f1a3876257400db529590.tar.gz
rails-c856d895bd054d0c474f1a3876257400db529590.tar.bz2
rails-c856d895bd054d0c474f1a3876257400db529590.zip
pass the mixin in to the code generation methods
-rw-r--r--activerecord/lib/active_record/associations/builder/association.rb12
-rw-r--r--activerecord/lib/active_record/associations/builder/collection_association.rb4
-rw-r--r--activerecord/lib/active_record/associations/builder/singular_association.rb6
3 files changed, 11 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb
index 5fa225f47a..a8559d9d2d 100644
--- a/activerecord/lib/active_record/associations/builder/association.rb
+++ b/activerecord/lib/active_record/associations/builder/association.rb
@@ -54,7 +54,7 @@ module ActiveRecord::Associations::Builder
end
def build
- define_accessors
+ define_accessors(mixin)
configure_dependency if options[:dependent]
reflection = ActiveRecord::Reflection.create(macro, name, scope, options, model)
Association.extensions.each do |extension|
@@ -82,12 +82,12 @@ module ActiveRecord::Associations::Builder
#
# Post.first.comments and Post.first.comments= methods are defined by this method...
- def define_accessors
- define_readers
- define_writers
+ def define_accessors(mixin)
+ define_readers(mixin)
+ define_writers(mixin)
end
- def define_readers
+ def define_readers(mixin)
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}(*args)
association(:#{name}).reader(*args)
@@ -95,7 +95,7 @@ module ActiveRecord::Associations::Builder
CODE
end
- def define_writers
+ def define_writers(mixin)
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}=(value)
association(:#{name}).writer(value)
diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb
index 5eb11f98c8..78000a3e3a 100644
--- a/activerecord/lib/active_record/associations/builder/collection_association.rb
+++ b/activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -61,7 +61,7 @@ module ActiveRecord::Associations::Builder
# Defines the setter and getter methods for the collection_singular_ids.
- def define_readers
+ def define_readers(mixin)
super
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
@@ -71,7 +71,7 @@ module ActiveRecord::Associations::Builder
CODE
end
- def define_writers
+ def define_writers(mixin)
super
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
diff --git a/activerecord/lib/active_record/associations/builder/singular_association.rb b/activerecord/lib/active_record/associations/builder/singular_association.rb
index 7bd894d6ab..5f0c3e0fdf 100644
--- a/activerecord/lib/active_record/associations/builder/singular_association.rb
+++ b/activerecord/lib/active_record/associations/builder/singular_association.rb
@@ -10,14 +10,14 @@ module ActiveRecord::Associations::Builder
true
end
- def define_accessors
+ def define_accessors(mixin)
super
- define_constructors if constructable?
+ define_constructors(mixin) if constructable?
end
# Defines the (build|create)_association methods for belongs_to or has_one association
- def define_constructors
+ def define_constructors(mixin)
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def build_#{name}(*args, &block)
association(:#{name}).build(*args, &block)