binarylogic-searchlogic 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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: binarylogic-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 -07:00
12
+ date: 2009-09-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,6 @@ files:
66
66
  - spec/spec_helper.rb
67
67
  has_rdoc: false
68
68
  homepage: http://github.com/binarylogic/searchlogic
69
- licenses:
70
69
  post_install_message:
71
70
  rdoc_options:
72
71
  - --charset=UTF-8
@@ -87,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
86
  requirements: []
88
87
 
89
88
  rubyforge_project: searchlogic
90
- rubygems_version: 1.3.5
89
+ rubygems_version: 1.2.0
91
90
  signing_key:
92
91
  specification_version: 3
93
92
  summary: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.