rails_or 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -4
- data/lib/rails_or.rb +9 -5
- data/lib/rails_or/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05147cdcf1a684a704627693759fb86d989e1cc8
|
4
|
+
data.tar.gz: f06041991f7a191226e14f35dd79a2af3346e9c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d970283a0d626ede46ad5be249dcb26f04faec42a744a954f61c972a8c43128a6e1169ea0df8108838c15b3990dbba885c16e2c88b0b3abdbb5a321d4da6873b
|
7
|
+
data.tar.gz: a715f7250ac45adf48d1cc85fabb6360002be6d2ce7d1a5656ab8be8cee657905c9bb2ae2f34ffceb93992dc96e2660b8596b61ebd75c0fa41db77e1b301d643
|
data/.travis.yml
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.2
|
4
|
-
|
5
|
-
|
3
|
+
- 2.2
|
4
|
+
- 2.3
|
5
|
+
sudo: required
|
6
|
+
dist: trusty
|
7
|
+
before_install:
|
8
|
+
- gem install bundler
|
9
|
+
- gem update --system
|
10
|
+
- gem --version
|
6
11
|
gemfile:
|
7
12
|
- gemfiles/3.2.gemfile
|
8
13
|
- gemfiles/4.2.gemfile
|
9
14
|
- gemfiles/5.0.gemfile
|
10
|
-
|
11
15
|
addons:
|
12
16
|
code_climate:
|
13
17
|
repo_token: 4be4fd5792acf886a179e8ebff97d155dc19858816d7179f2bf5002bae874818
|
data/lib/rails_or.rb
CHANGED
@@ -18,11 +18,7 @@ class ActiveRecord::Relation
|
|
18
18
|
mine = left_values - common
|
19
19
|
theirs = right_values - common
|
20
20
|
if mine.any? && theirs.any?
|
21
|
-
|
22
|
-
theirs.map!{ |x| String === x ? Arel.sql(x) : x }
|
23
|
-
mine = [Arel::Nodes::And.new(mine)] if mine.size > 1
|
24
|
-
theirs = [Arel::Nodes::And.new(theirs)] if theirs.size > 1
|
25
|
-
common << Arel::Nodes::Or.new(mine.first, theirs.first)
|
21
|
+
common << Arel::Nodes::Or.new(rails_or_values_to_arel(mine), rails_or_values_to_arel(theirs))
|
26
22
|
end
|
27
23
|
relation = rails_or_get_current_scope
|
28
24
|
relation.send("#{combining}_values=", common)
|
@@ -38,6 +34,14 @@ class ActiveRecord::Relation
|
|
38
34
|
self.or(klass.having(*args))
|
39
35
|
end
|
40
36
|
private
|
37
|
+
def rails_or_values_to_arel(values)
|
38
|
+
values.map!{|x| rails_or_wrap_arel(x) }
|
39
|
+
return (values.size > 1 ? Arel::Nodes::And.new(values) : values)
|
40
|
+
end
|
41
|
+
def rails_or_wrap_arel(node)
|
42
|
+
return node if Arel::Nodes::Equality === node
|
43
|
+
return Arel::Nodes::Grouping.new(String === node ? Arel.sql(node) : node)
|
44
|
+
end
|
41
45
|
def rails_or_parse_parameter(*other)
|
42
46
|
other = other.first if other.size == 1
|
43
47
|
case other
|
data/lib/rails_or/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_or
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|