accepts_nested_ids 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/accepts_nested_ids.rb +5 -11
- data/lib/accepts_nested_ids/nested_id_association.rb +11 -0
- data/lib/accepts_nested_ids/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 777e9c1455b2e3afe447967dd9bfef1a46e90647
|
4
|
+
data.tar.gz: a278c2a289613f95afbf230587b0729cafd21505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23c3f785a49ac7c4e4259fc1b484ffa4293cb403dfc780cacb77778f5c67a47f91c689397980aa28b87acfba20dc507151b64b0019a1a62604f9e6349193ba04
|
7
|
+
data.tar.gz: c42cbcf9c416117c52118ae8ca757dfab76b6c3a51e4e8a5d66dc310c9ca5b0fd514e8bd4ec03a9728f7df095faec822b43fc114f5faeab1232af1b6c4d00bc6
|
data/lib/accepts_nested_ids.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "accepts_nested_ids/version"
|
2
|
+
require "accepts_nested_ids/nested_id_association"
|
2
3
|
require "active_support/concern"
|
3
4
|
require "active_support/core_ext/string/inflections"
|
4
5
|
|
@@ -34,22 +35,15 @@ module AcceptsNestedIds
|
|
34
35
|
|
35
36
|
module ClassMethods
|
36
37
|
|
37
|
-
# Simple object that contains information about a nested ID association
|
38
|
-
#
|
39
|
-
# @param attr [Symbol] association attribute (ex: :documents)
|
40
|
-
# @param ids_attr [String] ids association attribute (ex: 'document_ids')
|
41
|
-
# @param class_name [String] association class name (ex: 'Document')
|
42
|
-
class NestedIdAssociation < Struct.new(:attr, :ids_attr, :class_name); end
|
43
|
-
|
44
38
|
# Sets up defered save and dirty tracking for the specified associations
|
45
39
|
#
|
46
40
|
# @example When class_name can be inferred from association name
|
47
41
|
# include AcceptsNestedIds
|
48
|
-
# accepts_nested_ids_for :documents, :
|
42
|
+
# accepts_nested_ids_for :documents, :users
|
49
43
|
#
|
50
44
|
# @example When class_name is different from association name
|
51
45
|
# include AcceptsNestedIds
|
52
|
-
# accepts_nested_ids_for :documents,
|
46
|
+
# accepts_nested_ids_for :documents, included_users: "User"
|
53
47
|
#
|
54
48
|
# @param args [Array]
|
55
49
|
def accepts_nested_ids_for(*args)
|
@@ -97,11 +91,11 @@ module AcceptsNestedIds
|
|
97
91
|
# Map module args into array of NestedIdAssociation objects with supporting properties
|
98
92
|
#
|
99
93
|
# @example
|
100
|
-
# accepts_nested_ids_for :documents,
|
94
|
+
# accepts_nested_ids_for :documents, included_users: "User"
|
101
95
|
# =>
|
102
96
|
# [
|
103
97
|
# { attr: :documents:, ids_attr: "document_ids", class_name: "Document"},
|
104
|
-
# { attr: :
|
98
|
+
# { attr: :included_users, ids_attr: "included_user_ids", class_name: "User" }
|
105
99
|
# ]
|
106
100
|
#
|
107
101
|
# @param args [Array]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module AcceptsNestedIds
|
2
|
+
|
3
|
+
# Simple object that contains information about a nested ID association
|
4
|
+
#
|
5
|
+
# @param attr [Symbol] association attribute (ex: :documents)
|
6
|
+
# @param ids_attr [String] ids association attribute (ex: 'document_ids')
|
7
|
+
# @param class_name [String] association class name (ex: 'Document')
|
8
|
+
class NestedIdAssociation < Struct.new(:attr, :ids_attr, :class_name)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accepts_nested_ids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuval Kordov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- bin/console
|
115
115
|
- bin/setup
|
116
116
|
- lib/accepts_nested_ids.rb
|
117
|
+
- lib/accepts_nested_ids/nested_id_association.rb
|
117
118
|
- lib/accepts_nested_ids/version.rb
|
118
119
|
homepage: http://github.com/uberllama/accepts_nested_ids
|
119
120
|
licenses:
|