search_scope 0.1.4 → 0.1.5
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/Rakefile +1 -1
- data/lib/search_scope.rb +8 -1
- data/search_scope.gemspec +2 -2
- metadata +2 -2
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('search_scope', '0.1.
|
5
|
+
Echoe.new('search_scope', '0.1.5') do |p|
|
6
6
|
p.description = "Simplify searching a model by defining custom named_scopes."
|
7
7
|
p.project = 'search-scope'
|
8
8
|
p.url = "http://rubyforge.org/projects/search-scope"
|
data/lib/search_scope.rb
CHANGED
@@ -12,6 +12,8 @@ module SearchScope
|
|
12
12
|
options[:order] ||= name.to_s
|
13
13
|
raise "you must supply a Symbol for a name to new_sortable_by (#{name.inspect})" unless name.is_a? Symbol
|
14
14
|
return if sort_choices_hash.keys.include? name.to_s
|
15
|
+
#the first sort added becomes the default sorting for all searches
|
16
|
+
@default_sort_choice ||= name
|
15
17
|
#TODO put this back and get rid of the return above once I figure out how to reset the class vars when the class is reloaded
|
16
18
|
# raise "there is already a sortable defined for the name (#{name.inspect}" if sort_choices_hash.keys.include? name.to_s
|
17
19
|
sort_choices_hash[name] = SortScope.new(name, options[:label], options[:order], options[:include])
|
@@ -41,6 +43,10 @@ module SearchScope
|
|
41
43
|
@search_scope_keys ||= []
|
42
44
|
end
|
43
45
|
|
46
|
+
def default_sort_choice
|
47
|
+
@default_sort_choice
|
48
|
+
end
|
49
|
+
|
44
50
|
def sort_choices
|
45
51
|
@sort_choices ||= []
|
46
52
|
end
|
@@ -76,7 +82,6 @@ module SearchScope
|
|
76
82
|
scopes << [key, term]
|
77
83
|
end
|
78
84
|
end
|
79
|
-
# scopes << [:sort_search_scope, options[:sort_by]] if options[:sort_by]
|
80
85
|
scopes
|
81
86
|
end
|
82
87
|
|
@@ -133,6 +138,8 @@ module SearchScope
|
|
133
138
|
unless params[:quick_search].blank?
|
134
139
|
aggregate_scope = aggregate_scope.scoped quick_search_scope_options(params[:quick_search])
|
135
140
|
end
|
141
|
+
|
142
|
+
params[:sort_by] ||= default_sort_choice
|
136
143
|
if params[:sort_by]
|
137
144
|
aggregate_scope = aggregate_scope.scoped sort_search_by_options(params[:sort_by])
|
138
145
|
end
|
data/search_scope.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{search_scope}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ryan Owens"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-07}
|
10
10
|
s.description = %q{Simplify searching a model by defining custom named_scopes.}
|
11
11
|
s.email = %q{ryan@infoether.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/search_scope.rb", "README"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Owens
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|