From b77dd218ce845f01753d02fcbc2605c9a5ee93e1 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Fri, 2 Apr 2010 17:34:48 +0100 Subject: Add Relation extensions --- activerecord/lib/active_record/named_scope.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/named_scope.rb') diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 9abf979cd0..3456332227 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -133,19 +133,16 @@ module ActiveRecord delegate :scopes, :with_scope, :with_exclusive_scope, :scoped_methods, :scoped, :to => :klass def self.init(klass, options, &block) - relation = new(klass, klass.arel_table) + relation = new(klass, klass.arel_table, &block) scope = if options.is_a?(Hash) - klass.scoped.apply_finder_options(options.except(:extend)) + klass.scoped.apply_finder_options(options) else options ? klass.scoped.merge(options) : klass.scoped end relation = relation.merge(scope) - Array.wrap(options[:extend]).each {|extension| relation.send(:extend, extension) } if options.is_a?(Hash) - relation.send(:extend, Module.new(&block)) if block_given? - relation.current_scoped_methods_when_defined = klass.send(:current_scoped_methods) relation end -- cgit v1.2.3