activerecord-where-any-of 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 39d578e488da080a1b42ef931dc686087641e94c
4
+ data.tar.gz: 9bf83b12a1a729aaa94fc7ff7dbf26a4d4e5af47
5
+ SHA512:
6
+ metadata.gz: 5b302de089cffa924b665ac1537d79891a8e06cefe514f1fc2b99fd7162be7c01a2bb7a7e2e27edabff2c709597cb6bd89ae4957346646f647bc7014272376a0
7
+ data.tar.gz: 4315d4941e3372568c825d0cf743581cd555ab0bdedebd7f986a1344e6e63d2fe45d1cb27d3b30e88dc91e0201d938d771519ab7fdb5558db93b9ff99bffdf20
@@ -0,0 +1,17 @@
1
+ module ActiveRecord
2
+ module WhereAnyOfMixin
3
+
4
+ def where_any_of(*conditions)
5
+ # Takes any number of scopes and OR them together
6
+ # into a new scope which can be combined with other scopes
7
+ conditions = conditions.map do |c|
8
+ if c.is_a? Symbol or c.is_a? String
9
+ c = self.unscoped.send(c)
10
+ end
11
+ c.where_values.reduce(:and)
12
+ end
13
+ where(conditions.reduce(:or))
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ require 'active_record'
2
+ require 'active_record/where-any-of-mixin'
3
+ ActiveRecord::Base.send(:extend, ActiveRecord::WhereAnyOfMixin)
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-where-any-of
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - David McCullars
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: |-
56
+ Provides a mechanism for OR'ing together one or more AREL relations. Normally when
57
+ one performs `SomeModel.where(condition_1).where(condition_2)`, the result is to AND
58
+ those conditions together. Unfortunately, there is no good way of OR'ing them without
59
+ converting the conditions into manual SQL. This mixin addresses that issue.
60
+ email:
61
+ - david.mccullars@gmail.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - lib/active_record/where-any-of-mixin.rb
67
+ - lib/activerecord-where-any-of.rb
68
+ homepage:
69
+ licenses: []
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.1.11
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A simple mixin to ActiveRecord::Base that allows OR'ing arel relations.
91
+ test_files: []