rails_or 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/rails_or.rb +6 -4
- data/lib/rails_or/version.rb +1 -1
- data/rails_or.gemspec +2 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7b1ec771bf9f285557e672b4ef9f35c373d3e8f
|
4
|
+
data.tar.gz: a7e535164ba64cb7e162acd5913e7691a6e10154
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a9ee331fccfe976f1cd71206bbee456b339a8f0125441b79d95b0457a129547e492db033188baa58c4b57e309c8217833438daf23a85b2dcd091bf9481d354
|
7
|
+
data.tar.gz: 14b69f148cab20a19821484b8204295faefa98652a62aa4397d175d62d08e5494a3f86b877b80c9a48ab1e74d04945fe994b116b4dd540701a8be474fb4d1559
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
[![Gem Version](https://
|
1
|
+
[![Gem Version](https://img.shields.io/gem/v/rails_or.svg?style=flat)](https://rubygems.org/gems/rails_or)
|
2
|
+
[![Build Status](https://travis-ci.org/khiav223577/rails_or.svg?branch=master)](https://travis-ci.org/khiav223577/rails_or)
|
3
|
+
[![RubyGems](http://img.shields.io/gem/dt/rails_or.svg?style=flat)](https://rubygems.org/gems/rails_or)
|
2
4
|
[![Code Climate](https://codeclimate.com/github/khiav223577/rails_or/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/rails_or)
|
3
5
|
[![Test Coverage](https://codeclimate.com/github/khiav223577/rails_or/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/rails_or/coverage)
|
4
|
-
[![Build Status](https://travis-ci.org/khiav223577/rails_or.svg?branch=master)](https://travis-ci.org/khiav223577/rails_or)
|
5
6
|
|
6
7
|
# RailsOr
|
7
8
|
|
data/lib/rails_or.rb
CHANGED
@@ -10,9 +10,10 @@ class ActiveRecord::Relation
|
|
10
10
|
end
|
11
11
|
else
|
12
12
|
def or(*other)
|
13
|
+
other = parse_or_parameter(*other)
|
13
14
|
combining = group_values.any? ? :having : :where
|
14
15
|
left_values = send("#{combining}_values")
|
15
|
-
right_values =
|
16
|
+
right_values = other.send("#{combining}_values")
|
16
17
|
common = left_values & right_values
|
17
18
|
mine = left_values - common
|
18
19
|
theirs = right_values - common
|
@@ -24,6 +25,7 @@ class ActiveRecord::Relation
|
|
24
25
|
common << Arel::Nodes::Or.new(mine.first, theirs.first)
|
25
26
|
end
|
26
27
|
send("#{combining}_values=", common)
|
28
|
+
self.bind_values = self.bind_values + other.bind_values
|
27
29
|
return self
|
28
30
|
end
|
29
31
|
end
|
@@ -31,9 +33,9 @@ private
|
|
31
33
|
def parse_or_parameter(*other)
|
32
34
|
other = other.first if other.size == 1
|
33
35
|
case other
|
34
|
-
when Hash ;
|
35
|
-
when Array ;
|
36
|
-
when String ;
|
36
|
+
when Hash ; klass.where(other)
|
37
|
+
when Array ; klass.where(other)
|
38
|
+
when String ; klass.where(other)
|
37
39
|
else ; other
|
38
40
|
end
|
39
41
|
end
|
data/lib/rails_or/version.rb
CHANGED
data/rails_or.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["khiav reoy"]
|
10
10
|
spec.email = ["mrtmrt15xn@yahoo.com.tw"]
|
11
11
|
|
12
|
-
spec.summary = %q{Support #or query method
|
13
|
-
spec.description = %q{#or query
|
12
|
+
spec.summary = %q{Support and entend #or query method.}
|
13
|
+
spec.description = %q{Support and entend #or query method in Rails 3, 4, 5.}
|
14
14
|
spec.homepage = "https://github.com/khiav223577/rails_or"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
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.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,8 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3'
|
83
|
-
description:
|
84
|
-
in Rails 3 and 4, too."
|
83
|
+
description: 'Support and entend #or query method in Rails 3, 4, 5.'
|
85
84
|
email:
|
86
85
|
- mrtmrt15xn@yahoo.com.tw
|
87
86
|
executables: []
|
@@ -126,5 +125,5 @@ rubyforge_project:
|
|
126
125
|
rubygems_version: 2.4.8
|
127
126
|
signing_key:
|
128
127
|
specification_version: 4
|
129
|
-
summary: 'Support #or query method
|
128
|
+
summary: 'Support and entend #or query method.'
|
130
129
|
test_files: []
|