From 5b527dc39d1e6dbfbe1515a88bf0ee77706f1ded Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 1 Aug 2013 11:55:09 -0700 Subject: push option handling "chrome" outside `initialize` --- .../lib/active_record/associations/builder/association.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index bdde25bd38..22bc005b05 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -24,6 +24,11 @@ module ActiveRecord::Associations::Builder def self.build(model, name, scope, options, &block) raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol) + if scope.is_a?(Hash) + options = scope + scope = nil + end + builder = new(name, scope, options, &block) reflection = builder.build(model) builder.define_accessors model @@ -34,14 +39,8 @@ module ActiveRecord::Associations::Builder def initialize(name, scope, options) @name = name - - if scope.is_a?(Hash) - @scope = nil - @options = scope - else - @scope = scope - @options = options - end + @scope = scope + @options = options validate_options -- cgit v1.2.3