rails_or 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56c4f804332574c8c5417b2350f7d7cf027e6b61
4
- data.tar.gz: a1ddd0de0517011145406f4b93a0451c3b678669
3
+ metadata.gz: e7b1ec771bf9f285557e672b4ef9f35c373d3e8f
4
+ data.tar.gz: a7e535164ba64cb7e162acd5913e7691a6e10154
5
5
  SHA512:
6
- metadata.gz: f1cd03c1f89e4f47138edd99edcac8c9fde233a1801fb1ea38f2d1af513a8c60cc8d14acdb765fd52e094da4ba08f2a214e20e1d6045bac4085e9676666086bb
7
- data.tar.gz: 38a7943e85c4a8fb585d26ba3b7477d407d84f7a6bdbc7fa2373e1f6e294e69179fa29b138907a9d42332447cb0dedd5e2b65054a3aa4103044b964818e9f3f4
6
+ metadata.gz: 87a9ee331fccfe976f1cd71206bbee456b339a8f0125441b79d95b0457a129547e492db033188baa58c4b57e309c8217833438daf23a85b2dcd091bf9481d354
7
+ data.tar.gz: 14b69f148cab20a19821484b8204295faefa98652a62aa4397d175d62d08e5494a3f86b877b80c9a48ab1e74d04945fe994b116b4dd540701a8be474fb4d1559
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- [![Gem Version](https://badge.fury.io/rb/rails_or.svg)](http://badge.fury.io/rb/rails_or)
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 = parse_or_parameter(*other).send("#{combining}_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 ; self.except(:where).where(other.to_a.map{|s| s[0] = "#{s[0]} = ?" ; next s}.flatten) #TODO why hash is not working?
35
- when Array ; self.except(:where).where(other)
36
- when String ; self.except(:where).where(other)
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
@@ -1,3 +1,3 @@
1
1
  module RailsOr
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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 in Rails 3, 4, 5}
13
- spec.description = %q{#or query is support only in new-coming Rails 5. This gem support it in Rails 3 and 4, too.}
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.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: 2016-12-29 00:00:00.000000000 Z
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: "#or query is support only in new-coming Rails 5. This gem support it
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 in Rails 3, 4, 5'
128
+ summary: 'Support and entend #or query method.'
130
129
  test_files: []