rails_or 1.1.7 → 1.1.8

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: 06d5dd12cf0c23251f01c2b591bf8f313e3e99e8
4
- data.tar.gz: 936f18b090e9f5b56bc483ce353aa347190d3956
3
+ metadata.gz: dcae3f6e02afc8e2b8f4d8924a0ee5f27d1faa47
4
+ data.tar.gz: c12eab9c2692aec32299f88a2bd1ea55fd100144
5
5
  SHA512:
6
- metadata.gz: f01e2a4d78a54f9d318088ca27d3c534ab149bebd53566df64b9cd84121f67ce994b8719f282766b029f0bc104919cb82405ccdd615968dc11059ea3021b776c
7
- data.tar.gz: 4420743158b6612111c00af6dd03e98fbb129aa0f20d70fe7b4cbc5ff30366de41101448b56de049cf8b512c0282b3ff93711cad0fd3aa1e99147856bd86402a
6
+ metadata.gz: 9e3aba494f94ac1445b54d00fe65770bd7864614d2a1c707e517e8bb64306d2f2bfe19aae3f3be29766e39c8c70c968b97202bfc486bfdf1632d6dce0663b62f
7
+ data.tar.gz: 719bc7b6cfcddb536f086f49d534ba3a5fbcefdde9f309743255477c946e6e91ea25f5f5982248525dee7ea4e7cbf21e8e299a1c86eda86cd246ef5b1a5a349e
@@ -12,6 +12,7 @@ gemfile:
12
12
  - gemfiles/3.2.gemfile
13
13
  - gemfiles/4.2.gemfile
14
14
  - gemfiles/5.0.gemfile
15
+ - gemfiles/5.1.gemfile
15
16
  addons:
16
17
  code_climate:
17
18
  repo_token: 4be4fd5792acf886a179e8ebff97d155dc19858816d7179f2bf5002bae874818
@@ -3,6 +3,10 @@
3
3
 
4
4
  - No changes.
5
5
 
6
+ ### RailsOr [1.1.8] - (March 14, 2018)
7
+
8
+ - Fix missing from_clause when using #from and #none together [[#23](https://github.com/khiav223577/rails_or/pull/23)] @khiav223577
9
+
6
10
  ### RailsOr [1.1.7] - (September 12, 2017)
7
11
 
8
12
  - Better Rails 5 Support. [[#21](https://github.com/khiav223577/rails_or/pull/21)] @khiav223577
@@ -59,7 +63,8 @@
59
63
  - Add #or method [[#1](https://github.com/khiav223577/rails_or/pull/1)] @khiav223577
60
64
  <br><br>
61
65
 
62
- [Unreleased]: https://github.com/khiav223577/rails_or/compare/v1.1.7...HEAD
66
+ [Unreleased]: https://github.com/khiav223577/rails_or/compare/v1.1.8...HEAD
67
+ [1.1.8]: https://github.com/khiav223577/rails_or/compare/v1.1.7...v1.1.8
63
68
  [1.1.7]: https://github.com/khiav223577/rails_or/compare/v1.1.6...v1.1.7
64
69
  [1.1.6]: https://github.com/khiav223577/rails_or/compare/v1.1.5...v1.1.6
65
70
  [1.1.5]: https://github.com/khiav223577/rails_or/compare/v1.1.4...v1.1.5
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_or.gemspec
4
+
5
+ gem "activerecord", "~> 5.1"
6
+
7
+ group :test do
8
+ gem "simplecov"
9
+ gem "codeclimate-test-reporter", "~> 1.0.0"
10
+ end
11
+
12
+ gemspec :path => "../"
13
+
@@ -2,9 +2,24 @@ require "rails_or/version"
2
2
  require "rails_or/where_binding_mixs"
3
3
  require 'active_record'
4
4
 
5
+ if defined?(ActiveRecord::NullRelation)
6
+ module ActiveRecord::NullRelation
7
+ if method_defined?(:or)
8
+ if not method_defined?(:rails5_or)
9
+ alias_method :rails5_or, :or
10
+ def or(*other)
11
+ rails5_or(rails_or_parse_parameter(*other))
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
5
18
  class ActiveRecord::Relation
6
19
  IS_RAILS3_FLAG = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
7
20
  IS_RAILS5_FLAG = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('5.0.0')
21
+ FROM_VALUE_METHOD = %i[from_value from_clause].find{|s| method_defined?(s) }
22
+ ASSIGN_FROM_VALUE = :"#{FROM_VALUE_METHOD}="
8
23
  if method_defined?(:or)
9
24
  if not method_defined?(:rails5_or)
10
25
  alias_method :rails5_or, :or
@@ -84,6 +99,7 @@ class ActiveRecord::Relation
84
99
 
85
100
  def rails_or_spwan_relation(method, condition)
86
101
  relation = klass.send(method, condition)
102
+ relation.send(ASSIGN_FROM_VALUE, send(FROM_VALUE_METHOD))
87
103
  rails_or_copy_values_to(relation) if IS_RAILS5_FLAG
88
104
  return relation
89
105
  end
@@ -1,3 +1,3 @@
1
1
  module RailsOr
2
- VERSION = "1.1.7"
2
+ VERSION = "1.1.8"
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.7
4
+ version: 1.1.8
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-09-12 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,6 +99,7 @@ files:
99
99
  - gemfiles/3.2.gemfile
100
100
  - gemfiles/4.2.gemfile
101
101
  - gemfiles/5.0.gemfile
102
+ - gemfiles/5.1.gemfile
102
103
  - lib/rails_or.rb
103
104
  - lib/rails_or/version.rb
104
105
  - lib/rails_or/where_binding_mixs.rb