activerecord-like 0.0.6 → 1.0.0
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 +4 -4
- data/.travis.yml +3 -3
- data/README.md +1 -1
- data/lib/active_record/like.rb +6 -0
- data/lib/active_record/like/version.rb +1 -1
- data/test/unit/like_test.rb +0 -4
- data/test/unit/not_like_test.rb +0 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5747b7416a46d6d651022ba3fa6924fd8db7a0
|
4
|
+
data.tar.gz: a12c215ff69771f33fc772c81c52328d553afc3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e1151781fee66992b46a476bf7390f56febd409616f31af9cf41a5c1c8e2354df120fb2927bc7a12983e04db7ff34947427cb1314c6ddfe36a38dd38c468d3
|
7
|
+
data.tar.gz: bcf5e1ee0ae802a3bdbf6ea1444e720e5e2a74ad540b88cf9e538ebdf0e35586172269bc54a932d3e255ee0c11d431ace76d79b43a8d3b119ef6f5e3769f5a20
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -43,7 +43,7 @@ Post.where.not_like(title: ["%ruby%", "%rails%"])
|
|
43
43
|
```
|
44
44
|
|
45
45
|
## Dependencies
|
46
|
-
Does not work with
|
46
|
+
Does not work with Arel 4.0.1 or lower or Arel 5.0.0. Do a `bundle update arel` to get the latest Arel that is compatible with your ActiveRecord version (4.0 for ActiveRecord 4.0, 5.0 for ActiveRecord 4.1).
|
47
47
|
|
48
48
|
## Contributing
|
49
49
|
|
data/lib/active_record/like.rb
CHANGED
@@ -4,6 +4,12 @@ module ActiveRecord
|
|
4
4
|
module QueryMethods
|
5
5
|
module Like
|
6
6
|
def like(opts, *rest)
|
7
|
+
opts.each do |k,v|
|
8
|
+
if v.is_a?(Array) && v.empty?
|
9
|
+
opts[k] = ''
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
chain_node(Arel::Nodes::Matches, opts, *rest) do |nodes|
|
8
14
|
nodes.inject { |memo, node| Arel::Nodes::Or.new(memo, node) }
|
9
15
|
end
|
data/test/unit/like_test.rb
CHANGED
@@ -19,10 +19,6 @@ describe ActiveRecord::QueryMethods::WhereChain do
|
|
19
19
|
it "has the attribute as the left operand" do
|
20
20
|
@relation_specifier.left.name.must_equal @attribute
|
21
21
|
end
|
22
|
-
|
23
|
-
it "has the value as the right operand" do
|
24
|
-
@relation_specifier.right.must_equal @value
|
25
|
-
end
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
data/test/unit/not_like_test.rb
CHANGED
@@ -19,10 +19,6 @@ describe ActiveRecord::QueryMethods::WhereChain do
|
|
19
19
|
it "has the attribute as the left operand" do
|
20
20
|
@relation_specifier.left.name.must_equal @attribute
|
21
21
|
end
|
22
|
-
|
23
|
-
it "has the value as the right operand" do
|
24
|
-
@relation_specifier.right.must_equal @value
|
25
|
-
end
|
26
22
|
end
|
27
23
|
end
|
28
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-like
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René van den Berg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.4.
|
69
|
+
rubygems_version: 2.4.6
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: 'ActiveRecord::Like provides ActiveRecord::Base with where.like(attribute:
|