rails_or 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_or.rb +7 -10
- 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: eb04bc9b28a161af5935120a35ed5a27a34293cb
|
4
|
+
data.tar.gz: 43af4e319dd0f7d77b00c7c7f25ec5444b4ea0b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2326a06c3c6cbab54864b790018f736818abdff7a0a8b9975e801fe1fef4e7ec40caee235fa3642c484c9096eaefc208400e7a37fa1761d81562b1b7a9fc44ec
|
7
|
+
data.tar.gz: d40665dcdbddd2886d4eba9bfbefb42b39b81b186652811c49e09a77beaaa30e1ed741e6eeba1a3f20a92c2ffdf3dca036965a2525d36d2e042fd6d8bd954261
|
data/lib/rails_or.rb
CHANGED
@@ -2,6 +2,7 @@ require "rails_or/version"
|
|
2
2
|
require 'active_record'
|
3
3
|
|
4
4
|
class ActiveRecord::Relation
|
5
|
+
IS_RAILS3_FLAG = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
|
5
6
|
if method_defined?(:or)
|
6
7
|
alias rails5_or or
|
7
8
|
def or(*other)
|
@@ -29,14 +30,9 @@ class ActiveRecord::Relation
|
|
29
30
|
return relation
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
else
|
37
|
-
def or_not(*args)
|
38
|
-
return self.or(klass.where.not(*args))
|
39
|
-
end
|
33
|
+
def or_not(*args)
|
34
|
+
raise 'This method is not support in Rails 3' if IS_RAILS3_FLAG
|
35
|
+
return self.or(klass.where.not(*args))
|
40
36
|
end
|
41
37
|
def or_having(*args)
|
42
38
|
self.or(klass.having(*args))
|
@@ -51,10 +47,11 @@ private
|
|
51
47
|
else ; other
|
52
48
|
end
|
53
49
|
end
|
54
|
-
RAILS_OR_GET_CURRENT_SCOPE_METHOD = (Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0') ? :clone : :all)
|
55
50
|
def rails_or_get_current_scope
|
51
|
+
return self.clone if IS_RAILS3_FLAG
|
56
52
|
#ref: https://github.com/rails/rails/blob/17ef58db1776a795c9f9e31a1634db7bcdc3ecdf/activerecord/lib/active_record/scoping/named.rb#L26
|
57
|
-
return self.
|
53
|
+
#return self.all # <- cannot use this because some gem changes this method's behavior
|
54
|
+
return (self.current_scope || self.default_scoped).clone
|
58
55
|
end
|
59
56
|
end
|
60
57
|
class ActiveRecord::Base
|
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.2
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|