Skip to content

Commit

Permalink
Remove unnecessary argument for creating scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Apr 3, 2010
1 parent 47c99f9 commit 684e4d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions activerecord/lib/active_record/named_scope.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def scope(name, options = {}, &block)
"Overwriting existing method #{self.name}.#{name}." "Overwriting existing method #{self.name}.#{name}."
end end


scopes[name] = lambda do |parent_scope, *args| scopes[name] = lambda do |*args|
scope_options = case options scope_options = case options
when Hash, Relation when Hash, Relation
options options
Expand All @@ -116,17 +116,17 @@ def scope(name, options = {}, &block)
end end


relation = if scope_options.is_a?(Hash) relation = if scope_options.is_a?(Hash)
parent_scope.scoped.apply_finder_options(scope_options) scoped.apply_finder_options(scope_options)
else else
scope_options ? parent_scope.scoped.merge(scope_options) : parent_scope.scoped scope_options ? scoped.merge(scope_options) : scoped
end end


block_given? ? relation.extending(Module.new(&block)) : relation block_given? ? relation.extending(Module.new(&block)) : relation
end end


singleton_class.instance_eval do singleton_class.instance_eval do
define_method name do |*args| define_method name do |*args|
scopes[name].call(self, *args) scopes[name].call(*args)
end end
end end
end end
Expand Down

0 comments on commit 684e4d3

Please sign in to comment.