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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb04bc9b28a161af5935120a35ed5a27a34293cb
4
- data.tar.gz: 43af4e319dd0f7d77b00c7c7f25ec5444b4ea0b3
3
+ metadata.gz: 05147cdcf1a684a704627693759fb86d989e1cc8
4
+ data.tar.gz: f06041991f7a191226e14f35dd79a2af3346e9c8
5
5
  SHA512:
6
- metadata.gz: 2326a06c3c6cbab54864b790018f736818abdff7a0a8b9975e801fe1fef4e7ec40caee235fa3642c484c9096eaefc208400e7a37fa1761d81562b1b7a9fc44ec
7
- data.tar.gz: d40665dcdbddd2886d4eba9bfbefb42b39b81b186652811c49e09a77beaaa30e1ed741e6eeba1a3f20a92c2ffdf3dca036965a2525d36d2e042fd6d8bd954261
6
+ metadata.gz: d970283a0d626ede46ad5be249dcb26f04faec42a744a954f61c972a8c43128a6e1169ea0df8108838c15b3990dbba885c16e2c88b0b3abdbb5a321d4da6873b
7
+ data.tar.gz: a715f7250ac45adf48d1cc85fabb6360002be6d2ce7d1a5656ab8be8cee657905c9bb2ae2f34ffceb93992dc96e2660b8596b61ebd75c0fa41db77e1b301d643
@@ -1,13 +1,17 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
4
- before_install: gem install bundler -v 1.11.2
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
@@ -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
- mine.map!{|x| String === x ? Arel.sql(x) : x }
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
@@ -1,3 +1,3 @@
1
1
  module RailsOr
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
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.2
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-14 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler