searchlogic 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,8 @@
1
- == 2.3.2 relased 2009-08-26
1
+ == 2.3.3 released 2009-09-02
2
+
3
+ * Split out merging scopes with 'or' into a convenient method.
4
+
5
+ == 2.3.2 released 2009-08-26
2
6
 
3
7
  * Add in scope_procedure as an alias for alias_scope.
4
8
  * Fixed bug with not_blank condition.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 3
3
- :patch: 2
2
+ :patch: 3
4
3
  :major: 2
4
+ :minor: 3
@@ -96,11 +96,21 @@ module Searchlogic
96
96
 
97
97
  def create_or_condition(scopes, args)
98
98
  named_scope scopes.join("_or_"), lambda { |*args|
99
- scopes_options = scopes.collect { |scope| send(scope, *args).proxy_options }
100
- conditions = scopes_options.reject { |o| o[:conditions].nil? }.collect { |o| sanitize_sql(o[:conditions]) }
101
- scopes.inject(scoped({})) { |scope, scope_name| scope.send(scope_name, *args) }.scope(:find).merge(:conditions => "(" + conditions.join(") OR (") + ")")
99
+ merge_scopes_with_or(scopes.collect { |scope| [scope, *args] })
102
100
  }
103
101
  end
102
+
103
+ def merge_scopes_with_or(scopes)
104
+ scopes_options = scopes.collect { |scope, *args| send(scope, *args).proxy_options }
105
+ conditions = scopes_options.reject { |o| o[:conditions].nil? }.collect { |o| sanitize_sql(o[:conditions]) }
106
+
107
+ scope = scopes.inject(scoped({})) do |scope, info|
108
+ scope_name, *args = info
109
+ scope.send(scope_name, *args)
110
+ end
111
+
112
+ scope.scope(:find).merge(:conditions => "(" + conditions.join(") OR (") + ")")
113
+ end
104
114
  end
105
115
  end
106
116
  end
data/searchlogic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{searchlogic}
8
- s.version = "2.3.2"
8
+ s.version = "2.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Johnson of Binary Logic"]
12
- s.date = %q{2009-08-26}
12
+ s.date = %q{2009-09-02}
13
13
  s.description = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
14
14
  s.email = %q{bjohnson@binarylogic.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-26 00:00:00 -04:00
12
+ date: 2009-09-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency