activerecord-setops 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: ff173ef86e3d6dd6452ef2e1a5c951dfc49b0fc82b17f39e2e295ea43673249f
4
- data.tar.gz: 50fc5f51616f9f744ca0345404fef5aad491fe177b0e70c6256e803330398714
3
+ metadata.gz: 19f77a7a5a20214036dc0394e28556788dcbbf95a9c78f8b502fe52fb551ec66
4
+ data.tar.gz: 9393dd62ceb050cd2605b9b112b7d3cd442e677398fb3ca1d13e7ec8cb836fca
5
5
  SHA512:
6
- metadata.gz: e576137f4f3e14464649548add2031a14cea8992b86330131dfe683de900c4168e39309320b73695827ace4be19bea198513af8719012520fb807d4d78ba6d89
7
- data.tar.gz: 3053deafd6157aedb983b1d70f8db24e4c6582fd222db9d87f63be7f7d28b6d7202913444ee71794248dfba3c071283ee863e998052fa29c16f9c1a5b372c020
6
+ metadata.gz: 6f52b0afedfca8afa3fe948c831fb0ab6db2e31d37618268ee0246e8248f903fa8e83f70ccc7d785603011d0a7bc836a55fa6badbd7aa29d6eb24834f3647f02
7
+ data.tar.gz: 8a8e060c36ab59c0f5b50dabe04d7071a8251fb0835ddecb8aa9682211767c5698000ccd76397f98525fa81217afbcabaa0edc7cad08645bc4a646407ccec420
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-setops (0.1.6)
4
+ activerecord-setops (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -38,6 +38,44 @@ Or install it yourself as:
38
38
 
39
39
  $ gem install activerecord-setops
40
40
 
41
+ # Non-Installation
42
+
43
+ If you'd like the functionality, but would prefer to avoid yet another dependency, please fill free to paste the following code into your nearest lib directory, I'm certain it's not perfect but it has been [tested](spec/active_record/setops_spec.rb) with Rails 5, and is being used in production.
44
+
45
+ ```ruby
46
+ module ActiveRecord
47
+ class Relation
48
+ # Performs a set theoretic union works like `Array#+` but puts the load on the database
49
+ # and allows you to chain more relation operations.
50
+ def union(other)
51
+ binary_operation(Arel::Nodes::Union, other)
52
+ end
53
+ alias | union
54
+ alias + union
55
+
56
+ def union_all(other)
57
+ binary_operation(Arel::Nodes::UnionAll, other)
58
+ end
59
+
60
+ def intersect(other)
61
+ binary_operation(Arel::Nodes::Intersect, other)
62
+ end
63
+ alias & intersect
64
+
65
+ def difference(other)
66
+ binary_operation(Arel::Nodes::Except, other)
67
+ end
68
+ alias - difference
69
+
70
+ private
71
+
72
+ def binary_operation(op_class, other)
73
+ @klass.unscoped.from(Arel::Nodes::TableAlias.new(op_class.new(self.arel.ast, other.arel.ast), @klass.arel_table.name))
74
+ end
75
+ end
76
+ end
77
+ ```
78
+
41
79
  # See Also
42
80
 
43
81
  - [Sequel](http://sequel.jeremyevans.net)
@@ -8,11 +8,11 @@ module ActiveRecord
8
8
  binary_operation(Arel::Nodes::Union, other)
9
9
  end
10
10
  alias | union
11
- alias + union
12
11
 
13
12
  def union_all(other)
14
13
  binary_operation(Arel::Nodes::UnionAll, other)
15
14
  end
15
+ alias + union_all
16
16
 
17
17
  def intersect(other)
18
18
  binary_operation(Arel::Nodes::Intersect, other)
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Setops
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-setops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delon Newman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler