restful_query 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/restful_query.rb +1 -1
- data/lib/restful_query/parser.rb +10 -6
- data/restful_query.gemspec +1 -1
- metadata +7 -7
data/History.txt
CHANGED
data/lib/restful_query.rb
CHANGED
data/lib/restful_query/parser.rb
CHANGED
@@ -10,7 +10,7 @@ module RestfulQuery
|
|
10
10
|
@single_sort = options[:single_sort] || true
|
11
11
|
@default_sort_options = options[:sort_options] || {}
|
12
12
|
@query = (query || {}).dup
|
13
|
-
@
|
13
|
+
@default_sort = options[:default_sort] ? [make_sort(options[:default_sort])] : []
|
14
14
|
@default_join = @query.delete(:join) || :and
|
15
15
|
extract_sorts_from_conditions
|
16
16
|
map_conditions
|
@@ -82,7 +82,7 @@ module RestfulQuery
|
|
82
82
|
new_sort.direction = direction
|
83
83
|
end
|
84
84
|
else
|
85
|
-
new_sort =
|
85
|
+
new_sort = make_sort(column, direction)
|
86
86
|
self.sorts << new_sort
|
87
87
|
end
|
88
88
|
new_sort
|
@@ -147,13 +147,17 @@ module RestfulQuery
|
|
147
147
|
def sorts_from_hash(sorts)
|
148
148
|
sort_conditions = [sorts].flatten.compact
|
149
149
|
sort_conditions.collect do |c|
|
150
|
-
|
151
|
-
s.column = map_column(s.column)
|
152
|
-
s.options = default_sort_options
|
153
|
-
s
|
150
|
+
make_sort(c)
|
154
151
|
end
|
155
152
|
end
|
156
153
|
|
154
|
+
def make_sort(*condition)
|
155
|
+
s = Sort.parse(condition.flatten.join(' '))
|
156
|
+
s.column = map_column(s.column)
|
157
|
+
s.options = default_sort_options
|
158
|
+
s
|
159
|
+
end
|
160
|
+
|
157
161
|
def columns_from_options(column_type, options)
|
158
162
|
option = "#{column_type}_columns".to_sym
|
159
163
|
options[option] ? [options.delete(option)].flatten.collect {|c| c.to_s } : []
|
data/restful_query.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
requirement: &
|
17
|
+
requirement: &2151840860 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 2.2.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2151840860
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: chronic
|
28
|
-
requirement: &
|
28
|
+
requirement: &2151839320 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.2.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2151839320
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: Shoulda
|
39
|
-
requirement: &
|
39
|
+
requirement: &2151837540 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: 1.2.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2151837540
|
48
48
|
description: RestfulQuery provides a simple interface in front of a complex parser
|
49
49
|
to parse specially formatted query hashes into complex SQL queries. It includes
|
50
50
|
ActiveRecord and Sequel extensions.
|