source_ids 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 +4 -1
- data/lib/source_ids/version.rb +1 -1
- data/lib/source_ids.rb +7 -0
- 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: 9d31a494ef95c40e92a2c5b44679b90f745e5958
|
4
|
+
data.tar.gz: 21313bd507347ede7672cbc94aa7b88685fb96ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7887634128e6260d3edf646dfd87d7461e8188b835eab259fbbf5c3ca3ec3aca14900d650983c394cdf0d2810fd9722e255d6111e917d876ed0aea8ea0857f4
|
7
|
+
data.tar.gz: acafedda3ba6639742f7e7bdbec984b8f754dbd355832747a3dd04dd25c2e4926dd7b8ccbb8bcced93781093fedf420a994ddb028e49cad9822a2817ac15e2f6
|
data/README.md
CHANGED
@@ -34,7 +34,10 @@ To enable _user_ids=, add like this.
|
|
34
34
|
|
35
35
|
accepts_source_ids_for :users
|
36
36
|
|
37
|
-
This also add
|
37
|
+
This also add following methods.
|
38
|
+
|
39
|
+
* _user_ids - returns active (not marked for destruction) records' ids.
|
40
|
+
* _users - return source records via relation objects (relation objects may be changed but not saved yet).
|
38
41
|
|
39
42
|
## Contributing
|
40
43
|
|
data/lib/source_ids/version.rb
CHANGED
data/lib/source_ids.rb
CHANGED
@@ -11,6 +11,7 @@ module SourceIds
|
|
11
11
|
raise "Could not find association #{source_association_name}" unless source_association
|
12
12
|
relation = source_association.through_reflection
|
13
13
|
raise "#{source_association_name} does not have :through" unless relation
|
14
|
+
source_name = source_association.source_reflection.name
|
14
15
|
fk_in_relation = source_association.source_reflection.foreign_key
|
15
16
|
source_ids_name = options[:as] || "#{source_association_name.to_s.singularize}_ids"
|
16
17
|
|
@@ -43,9 +44,15 @@ module SourceIds
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
47
|
+
# _source_ids
|
46
48
|
define_method "_#{source_ids_name}" do
|
47
49
|
send(relation.name).find_all{|r| !r.marked_for_destruction?}.map(&fk_in_relation.to_sym)
|
48
50
|
end
|
51
|
+
|
52
|
+
# _sources
|
53
|
+
define_method "_#{source_association_name}" do
|
54
|
+
send(relation.name).find_all{|r| !r.marked_for_destruction?}.map(&source_name)
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: source_ids
|
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
|
- nay3
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|