activerecord-where-any-of 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21cdcf0e5b019222b778393fe10e65d57796a3b3
4
- data.tar.gz: ca0c4ae26fb2aa08e56ed62b76632d1d43234d50
3
+ metadata.gz: d0e626da34af089d9f92dcf9ee6d5b97395ffdb4
4
+ data.tar.gz: 891e420029939a94032a74d6f937caddf6177dc2
5
5
  SHA512:
6
- metadata.gz: fe382b7a5b770bda3ca9f6094c9880bbf7f3f45f84289a02cc30e848f488fee4295902600c5ebc07d7cf4c9441a4558284ad01098fc0b8079207b5491547da18
7
- data.tar.gz: a5970759d887334f936c72003fa6d9b284a1d992cbfaa3f9a086605c1b8ed920897b090b2d96869acee6da4aece663347083a2832b073763170c6807cea2f027
6
+ metadata.gz: 75c4e9ad19c7ab0132add54522a76d2815143ef36059b340f5f181c8d0a0d55989bfbc38aba429bcfb5ab95cbee685739538bd95f56c3528cc4aa096e55cea06
7
+ data.tar.gz: 784d559cd7de12e7a60599eed0ecaeb5c3cf95c2b448bb19537ef07260cdfad17f5db4e7bdd9aecaab2e523f6bc685626e54973f369396d5de177aaff7ca8396
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .dat*
6
+ .repl_history
7
+ .rvmrc
8
+ .yardoc
9
+ /.bundle/
10
+ /.config
11
+ /.yardoc/
12
+ /InstalledFiles
13
+ /_yardoc/
14
+ /coverage/
15
+ /doc/
16
+ /lib/bundler/man/
17
+ /pkg/
18
+ /rdoc/
19
+ /spec/reports/
20
+ /test/tmp/
21
+ /test/version_tmp/
22
+ /tmp/
23
+ Gemfile.lock
24
+ InstalledFiles
25
+ _yardoc
26
+ build/
27
+ coverage
28
+ doc/
29
+ lib/bundler/man
30
+ pkg
31
+ rdoc
32
+ spec/reports
33
+ test/tmp
34
+ test/version_tmp
35
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014-2015 David McCullars<david.mccullars@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ activerecord-where-any-of
2
+ =========================
3
+
4
+ Description:
5
+ -----------
6
+
7
+ Provides a mechanism for OR'ing together one or more AREL relations. Normally when
8
+ one performs `SomeModel.where(condition_1).where(condition_2)`, the result is to AND
9
+ those conditions together. Unfortunately, there is no good way of OR'ing them without
10
+ converting the conditions into manual SQL. This mixin addresses that issue.
11
+
12
+ Usage:
13
+ ------
14
+
15
+ `where_any_of` accepts any number of relations, symbols, or strings. For symbols and strings,
16
+ the corresponding method is called (unscoped) which is expected to return a relation.
17
+
18
+ ```rb
19
+ class SomeRecord < ActiveRecord::Base
20
+
21
+ default_scope do
22
+ where('extra is not null')
23
+ end
24
+
25
+ def self.owned_by(user)
26
+ where(:owner => user)
27
+ end
28
+
29
+ def self.active
30
+ where(:active => true)
31
+ end
32
+
33
+ def self.pending
34
+ where(:pending => true)
35
+ end
36
+
37
+ def self.active_or_pending
38
+ # Use symbols to make sure calls are unscoped
39
+ where_any_of(:active, :pending)
40
+ end
41
+
42
+ end
43
+ ```
44
+
45
+ ```rb
46
+ puts SomeRecord.owned_by('Fred').active_or_pending.to_sql
47
+ ```
48
+
49
+ > SELECT "some_records".* FROM "some_records"
50
+ > WHERE "some_records"."owner" = 'Fred' AND (extra is not null) AND (("some_records"."active" = 't' OR "some_records"."pending" = 't'))
51
+
52
+ ```rb
53
+ puts SomeRecord.where_any_of(
54
+ SomeRecord.where(:extra => 'A'),
55
+ SomeRecord.owned_by('Bill'),
56
+ 'active'
57
+ ).to_sql
58
+ ```
59
+
60
+ > SELECT "some_records".* FROM "some_records"
61
+ > WHERE (extra is not null) AND ((("some_records"."extra" = 'A' OR "some_records"."owner" = 'Bill') OR "some_records"."active" = 't'))
62
+
63
+ Install:
64
+ --------
65
+
66
+ In your app, add this line to your `Gemfile`:
67
+
68
+ ```rb
69
+ gem "activerecord-where-any-of"
70
+ ```
71
+
72
+ Then type `bundle`.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'activerecord-where-any-of'
3
+ s.version = '1.0.5'
4
+ s.license = 'MIT'
5
+ s.date = '2014-07-24'
6
+ s.summary = 'A simple mixin to ActiveRecord::Base that allows use of OR arel relations.'
7
+ s.description = '...'
8
+ s.description = File.read(File.expand_path('../README.md', __FILE__))[/Description:\n-+\s*(.*?)\n\n/m, 1]
9
+ s.authors = ['David McCullars']
10
+ s.email = ['david.mccullars@gmail.com']
11
+
12
+ s.require_paths = ['lib']
13
+ s.files = `git ls-files -z`.split("\x0")
14
+
15
+ s.add_runtime_dependency 'activerecord', '>= 3.0'
16
+ s.add_development_dependency 'bundler', '>= 1.3'
17
+ s.add_development_dependency 'rake'
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-where-any-of
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David McCullars
@@ -63,10 +63,17 @@ executables: []
63
63
  extensions: []
64
64
  extra_rdoc_files: []
65
65
  files:
66
+ - ".gitignore"
67
+ - Gemfile
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - activerecord-where-any-of.gemspec
66
72
  - lib/active_record/where-any-of-mixin.rb
67
73
  - lib/activerecord-where-any-of.rb
68
74
  homepage:
69
- licenses: []
75
+ licenses:
76
+ - MIT
70
77
  metadata: {}
71
78
  post_install_message:
72
79
  rdoc_options: []
@@ -87,5 +94,5 @@ rubyforge_project:
87
94
  rubygems_version: 2.2.2
88
95
  signing_key:
89
96
  specification_version: 4
90
- summary: A simple mixin to ActiveRecord::Base that allows OR'ing arel relations.
97
+ summary: A simple mixin to ActiveRecord::Base that allows use of OR arel relations.
91
98
  test_files: []