mobility-ransack 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +3 -1
- data/README.md +1 -1
- data/lib/mobility/plugins/ransack.rb +14 -5
- data/lib/mobility/ransack/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b666246ec54369683b3ca4c47ab7a37b276b8f6edd105dbfe001438dc8946b63
|
4
|
+
data.tar.gz: 2c6bc9c9703f0a1a14f6eea1ca53bd1098b685d4964e8f2ba926ed801e95de67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 294f956b8dbbfee07354f44f6fd3a27f58f234d274e7361501adb84472c59918f4e133641d140d1e71f0f20e6584af4b961a649d84523737ed1aa3916ccdc408
|
7
|
+
data.tar.gz: 931b32c4430f2623434012710b6436245ddabe1b7522d6b1f703a0038ae7b18d5382daf563a260a77b18d1dbfd3df72d75bd4ea1ae24b0e5a7d737d64eacadf9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Mobility Ransack Changelog
|
2
2
|
|
3
|
+
## 0.2
|
4
|
+
|
5
|
+
### 0.2.0
|
6
|
+
|
7
|
+
- Support sorting on translated attributes
|
8
|
+
([#2](https://github.com/shioyama/mobility-ransack/pull/2))
|
9
|
+
|
3
10
|
## 0.1
|
4
11
|
|
5
12
|
### 0.1.1
|
@@ -9,5 +16,7 @@
|
|
9
16
|
### 0.1.0
|
10
17
|
- Loosen Ransack dependency to allow up to 2.1
|
11
18
|
|
19
|
+
## 0.0
|
20
|
+
|
12
21
|
### 0.0.1
|
13
22
|
- Add plugin code.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mobility-ransack (0.1.
|
4
|
+
mobility-ransack (0.1.1)
|
5
5
|
mobility (~> 0.8.0)
|
6
6
|
ransack (>= 1.8.0, < 2.1)
|
7
7
|
|
@@ -55,6 +55,7 @@ GEM
|
|
55
55
|
coderay (1.1.2)
|
56
56
|
concurrent-ruby (1.0.5)
|
57
57
|
crass (1.0.4)
|
58
|
+
database_cleaner (1.7.0)
|
58
59
|
diff-lcs (1.3)
|
59
60
|
erubi (1.7.1)
|
60
61
|
globalid (0.4.1)
|
@@ -153,6 +154,7 @@ PLATFORMS
|
|
153
154
|
ruby
|
154
155
|
|
155
156
|
DEPENDENCIES
|
157
|
+
database_cleaner (~> 1.7.0)
|
156
158
|
mobility-ransack!
|
157
159
|
pry
|
158
160
|
pry-byebug
|
data/README.md
CHANGED
@@ -26,11 +26,20 @@ module Mobility
|
|
26
26
|
|
27
27
|
class Search < ::Ransack::Search
|
28
28
|
def result(opts = {})
|
29
|
-
|
30
|
-
predicate =
|
31
|
-
(
|
32
|
-
|
33
|
-
|
29
|
+
sorted = sorts.inject(super) do |relation, sort|
|
30
|
+
predicate = ::Ransack::Visitor.new.visit_Ransack_Nodes_Sort(sort)
|
31
|
+
apply_mobility_scope(relation, predicate, [sort.attr_name])
|
32
|
+
end
|
33
|
+
conditions.inject(sorted) do |relation, condition|
|
34
|
+
apply_mobility_scope(relation, condition.arel_predicate, condition.attributes.compact.flatten.map(&:name))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def apply_mobility_scope(relation, predicate, attributes)
|
41
|
+
(attributes & object.mobility_attributes).inject(relation) do |i18n_rel, attr|
|
42
|
+
object.mobility_backend_class(attr).apply_scope(i18n_rel, predicate)
|
34
43
|
end
|
35
44
|
end
|
36
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobility-ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: database_cleaner
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.7.0
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.7.0
|
89
103
|
description:
|
90
104
|
email:
|
91
105
|
- chris@dejimata.com
|