aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-31 17:27:51 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-31 17:28:08 -0700
commita9087ab25a2886e724cd58448315aad3fa8005ae (patch)
treeff4b4fe873aec68f44be12590c14e3b22dc0ccd9 /activerecord
parenta6f568acc60a44c3b01f133517ff61b3b520142b (diff)
downloadrails-a9087ab25a2886e724cd58448315aad3fa8005ae.tar.gz
rails-a9087ab25a2886e724cd58448315aad3fa8005ae.tar.bz2
rails-a9087ab25a2886e724cd58448315aad3fa8005ae.zip
push some validation up to the factory method
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/builder/association.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb
index 6b6a088806..a4faeeedec 100644
--- a/activerecord/lib/active_record/associations/builder/association.rb
+++ b/activerecord/lib/active_record/associations/builder/association.rb
@@ -22,13 +22,14 @@ module ActiveRecord::Associations::Builder
attr_reader :model, :name, :scope, :options
- def self.build(*args, &block)
- new(*args, &block).build
+ def self.build(model, name, scope, options, &block)
+ raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)
+
+ builder = new(model, name, scope, options, &block)
+ builder.build
end
def initialize(model, name, scope, options)
- raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)
-
@model = model
@name = name