source_ids 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cefbe74627840ff44a086a997e80f51dc479239
4
- data.tar.gz: e91547f4d99e8f70d8f099e0955695d07521aa3d
3
+ metadata.gz: 9d31a494ef95c40e92a2c5b44679b90f745e5958
4
+ data.tar.gz: 21313bd507347ede7672cbc94aa7b88685fb96ba
5
5
  SHA512:
6
- metadata.gz: f2a6433b0e8764ce9c71bc28f74307b4e1df5ba21559478b1b563821939e3840a93d7d94ead2665e9d4ab05578e278424d764f3584cfab2848015810d4d9012c
7
- data.tar.gz: e38259a69f69ec6ae046f26955bc7e7dabfe2c78e42d370459e3bb18eeb2feeb73189d3647aaf030dfb56fbf3cd3b92eea288854f713c318823eddd58779c31c
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 _user_ids method that returns active (not marked for destruction) records' ids.
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
 
@@ -1,3 +1,3 @@
1
1
  module SourceIds
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-07 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler