null_object_associations 0.0.2 → 0.0.3
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/README.md +14 -2
- data/lib/null_object_associations/version.rb +1 -1
- data/lib/null_object_associations.rb +2 -2
- data/null_object_associations.gemspec +1 -0
- 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: ec54733cb9a19b534fc4e4e1367225b47efb8b0c
|
4
|
+
data.tar.gz: 428d02802a7b92e6b05d2c9bd2ac92baf3a4b04e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006600669387070cb0e165d96dd8095495f3a41c2b5ed1d3ec9e5eb95ca84689b2650024fa59c14f736df66ed3be188161c09f5fa525b1f2ff5bd38b68f16a27
|
7
|
+
data.tar.gz: 11ca8d6c59624e178102cb0acc4ebd0ad9caa62c797029f5de9e2e8ad4ad89a5f44f1f47832a585ec245c7988dcc00d6337909a1834915783ffa53565e01944e
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# NullObjectAssociations
|
2
2
|
|
3
|
-
|
3
|
+
Return empty arrays or nil for associations. A nice little addition to null objects. Especially nice for those used in Rails.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,19 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
```
|
24
|
+
class NullUser
|
25
|
+
include NullObjectAssociations
|
26
|
+
|
27
|
+
has_many :friends
|
28
|
+
has_many :cousins, respond_to: [:pluck, :completed]
|
29
|
+
has_many :cars, respond_to: :any
|
30
|
+
has_and_belongs_to_many :accounts, respond_to: [:pluck, :completed]
|
31
|
+
has_one :house
|
32
|
+
belongs_to :spouse
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
24
36
|
|
25
37
|
## Contributing
|
26
38
|
|
@@ -43,9 +43,9 @@ module NullObjectAssociations
|
|
43
43
|
def build_associations(actions)
|
44
44
|
empty_array = []
|
45
45
|
|
46
|
-
empty_array.tap do |
|
46
|
+
empty_array.tap do |empty_arr|
|
47
47
|
actions.each do |action|
|
48
|
-
|
48
|
+
empty_arr.define_singleton_method(action) do
|
49
49
|
[]
|
50
50
|
end
|
51
51
|
end
|
@@ -9,6 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Karmen Blake"]
|
10
10
|
spec.email = ["dudeblake@gmail.com"]
|
11
11
|
spec.summary = %q{Handle associations in your null objects.}
|
12
|
+
spec.description = %q{Return empty arrays or nil for associations.}
|
12
13
|
spec.homepage = "https://github.com/kblake/null_object_associations"
|
13
14
|
spec.license = "MIT"
|
14
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: null_object_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karmen Blake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description:
|
41
|
+
description: Return empty arrays or nil for associations.
|
42
42
|
email:
|
43
43
|
- dudeblake@gmail.com
|
44
44
|
executables: []
|