Skip to content
Browse files

add_existing_scopes :this, :that

  • Loading branch information...
1 parent 4989067 commit 5bcc52d0c3fe11b9f9a4a85fea0074f31d194545 @towski towski committed Sep 18, 2008
Showing with 9 additions and 4 deletions.
  1. +7 −1 lib/can_search/search_scopes.rb
  2. +2 −3 spec/search_scopes_spec.rb
View
8 lib/can_search/search_scopes.rb
@@ -31,6 +31,12 @@ def add_existing_scope(name)
@scopes[name] = BaseScope.new(@model, name, :named_scope => name)
end
+ def add_existing_scopes(*names)
+ names.each do |name|
+ @scopes[name] = BaseScope.new(@model, name, :named_scope => name)
+ end
+ end
+
def [](name)
@scopes[name]
end
@@ -116,4 +122,4 @@ def ==(other)
end
send respond_to?(:require_dependency) ? :require_dependency : :require, 'can_search/date_range_scope'
-send respond_to?(:require_dependency) ? :require_dependency : :require, 'can_search/like_query_scope'
+send respond_to?(:require_dependency) ? :require_dependency : :require, 'can_search/like_query_scope'
View
5 spec/search_scopes_spec.rb
@@ -73,8 +73,7 @@ module CanSearch
@scope = Record.named_scope :example, lambda { |name| {:conditions => {:name => name} } }
Record.named_scope :peanut_butter, lambda { |id| {:conditions => {:parent_id => id} } }
Record.can_search do
- add_existing_scope :example
- add_existing_scope :peanut_butter
+ add_existing_scopes :example, :peanut_butter
end
end
@@ -94,4 +93,4 @@ module CanSearch
end
end
end
-end
+end

0 comments on commit 5bcc52d

Please sign in to comment.
Something went wrong with that request. Please try again.