duck_puncher 4.4.2 → 4.5.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/CHANGELOG.md +6 -0
- data/lib/duck_puncher/ducks/active_record.rb +54 -48
- data/lib/duck_puncher/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: 197f08e7d41195a8d4d8281175dad2923da0a80d
|
4
|
+
data.tar.gz: f8591266f5145352bdb4a9847e13ed84d6f67e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05b387372a27b20a7d31a96d6e6b0cce79f59c963f0456925a3cd65c90a3514b87db0fda498c6dd597f7abdec179831b6c04c29eee9c8aaefe33aad24fa11b2b
|
7
|
+
data.tar.gz: ea1ebe0ec61c32f7f0c3e3899a5dd21897cf43e702dd7688b97d5995135530380225a5e35663b106f53fd5ca1e450f973e85a15cab3d7ac76c8806d4a2f4daed
|
data/CHANGELOG.md
CHANGED
@@ -1,50 +1,56 @@
|
|
1
1
|
module DuckPuncher
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
2
|
+
module Ducks
|
3
|
+
module ActiveRecord
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
def associations?
|
9
|
+
associations.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
def associations
|
13
|
+
reflections.select { |key, reflection|
|
14
|
+
begin
|
15
|
+
if reflection.macro.to_s =~ /many/
|
16
|
+
send(key).exists?
|
17
|
+
else
|
18
|
+
send(key).present?
|
19
|
+
end
|
20
|
+
rescue
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
}.keys
|
24
|
+
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
def except_for(*ids)
|
28
|
+
scoped.where("#{quoted_table_name}.#{primary_key} NOT IN (?)", ids)
|
29
|
+
end
|
30
|
+
|
31
|
+
def since(time)
|
32
|
+
scoped.where("#{quoted_table_name}.created_at > ?", time)
|
33
|
+
end
|
34
|
+
|
35
|
+
alias created_since since
|
36
|
+
|
37
|
+
def before(time)
|
38
|
+
scoped.where("#{quoted_table_name}.created_at < ?", time)
|
39
|
+
end
|
40
|
+
|
41
|
+
def updated_since(time)
|
42
|
+
scoped.where("#{quoted_table_name}.updated_at > ?", time)
|
43
|
+
end
|
44
|
+
|
45
|
+
def between(start_at, end_at)
|
46
|
+
scoped.where("#{quoted_table_name}.created_at BETWEEN ? AND ", start_at, end_at)
|
47
|
+
end
|
48
|
+
|
49
|
+
# shim for backwards compatibility with Rails 3
|
50
|
+
def scoped
|
51
|
+
where(nil)
|
52
|
+
end if ::Rails::VERSION::MAJOR > 3
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
50
56
|
end
|
data/lib/duck_puncher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_puncher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: usable
|