source_ids 0.0.5 → 0.0.6

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: 9eae94e024e26c29e17635515950b3dec3d0d4de
4
- data.tar.gz: 41fe1a6d35230e90e949333c051884dc1e1fc1d6
3
+ metadata.gz: 162b8ff56a263000ad1c34c9886bf7dbcd2b474f
4
+ data.tar.gz: 86310243427fd118d9d21d25129129eff6c3c7b1
5
5
  SHA512:
6
- metadata.gz: 0ae90ae4b4e693dcf1dd82235bc16027723c0d4944a91e9eee0085667f9fbae085fecccb35791ef9d42a108580150160e2c9f03d637f2a772bd836c0ab2e0ac7
7
- data.tar.gz: 94c3c3791f97afd51e2c14f0aabc1b689ac8ed3c193ce721d442352529d0c16d86bc159ded70ef96a412b04b990b3ae6a6d0255eb059ca21cde65f7aaf0a773c
6
+ metadata.gz: 0e9ed11c2c4a6b839bef80c3f8667f61fab36e76f0f24fd9bf254eb8c995a63a7fccb4cc44375159b402c7883644ad28198adb1f195480f931022f0592b22f76
7
+ data.tar.gz: 43572c3c4f923df3751aa46c524d0d95e563dc5c1e01c2e8ab843e4b636d35146f561b5a946eda34c25bd4595f434de07d402a0dd7201420a9bba82c51e9c5c5
@@ -19,10 +19,14 @@ module SourceIds
19
19
  define_method "_#{source_ids_name}=" do |ids|
20
20
  ids = ids.find_all(&:present?).map(&:to_s) # care for hidden field of collection_select
21
21
 
22
- # mark destruction if not included in ids
23
- send(relation.name).each do |r|
24
- source_id = r.send(fk_in_relation)
25
- r.mark_for_destruction unless ids.include?(source_id.to_s)
22
+ # removing
23
+ removed = send(relation.name).find_all{|r| !ids.include?(r.send(fk_in_relation).to_s) }
24
+ removed.each do |r|
25
+ if r.new_record?
26
+ send(relation.name).delete(r)
27
+ else
28
+ r.mark_for_destruction
29
+ end
26
30
  end
27
31
 
28
32
  ids.each do |source_id|
@@ -1,3 +1,3 @@
1
1
  module SourceIds
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  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.5
4
+ version: 0.0.6
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-12 00:00:00.000000000 Z
11
+ date: 2013-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler