public
Description: Build common named scopes automatically, and provide a simple way to merge them with a single #search call.
Clone URL: git://github.com/technoweenie/can_search.git
Click here to lend your support to: can_search and make a donation at www.pledgie.com !
add_existing_scopes :this, :that
towski (author)
Thu Sep 18 11:04:36 -0700 2008
commit  5bcc52d0c3fe11b9f9a4a85fea0074f31d194545
tree    13b4c938f8d6c6977641effae374d1d17abcd56d
parent  49890673aef1adbfb8f920314d785072439d6402
...
31
32
33
 
 
 
 
 
 
34
35
36
...
116
117
118
119
120
 
...
31
32
33
34
35
36
37
38
39
40
41
42
...
122
123
124
 
125
126
0
@@ -31,6 +31,12 @@ module CanSearch
0
       @scopes[name] = BaseScope.new(@model, name, :named_scope => name)
0
     end
0
 
0
+ def add_existing_scopes(*names)
0
+ names.each do |name|
0
+ @scopes[name] = BaseScope.new(@model, name, :named_scope => name)
0
+ end
0
+ end
0
+
0
     def [](name)
0
       @scopes[name]
0
     end
0
@@ -116,4 +122,4 @@ module CanSearch
0
 end
0
 
0
 send respond_to?(:require_dependency) ? :require_dependency : :require, 'can_search/date_range_scope'
0
-send respond_to?(:require_dependency) ? :require_dependency : :require, 'can_search/like_query_scope'
0
\ No newline at end of file
0
+send respond_to?(:require_dependency) ? :require_dependency : :require, 'can_search/like_query_scope'
...
73
74
75
76
77
 
78
79
80
...
94
95
96
97
98
 
...
73
74
75
 
 
76
77
78
79
...
93
94
95
 
96
97
0
@@ -73,8 +73,7 @@ module CanSearch
0
         @scope = Record.named_scope :example, lambda { |name| {:conditions => {:name => name} } }
0
         Record.named_scope :peanut_butter, lambda { |id| {:conditions => {:parent_id => id} } }
0
         Record.can_search do
0
- add_existing_scope :example
0
- add_existing_scope :peanut_butter
0
+ add_existing_scopes :example, :peanut_butter
0
         end
0
       end
0
       
0
@@ -94,4 +93,4 @@ module CanSearch
0
       end
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments

    No one has commented yet.