ika 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ika/version.rb +1 -1
  3. data/lib/ika.rb +9 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 429195ee410ec2c9415df65d5f844406af9076c0
4
- data.tar.gz: f78c21e9a921f3139c8664418f00313a6f6c4e19
3
+ metadata.gz: 3abad6f8697c03b9a6d50c631c0acf8b5d8fbf7a
4
+ data.tar.gz: 4e9571c823550eba97df6c48c40f9201efee97ba
5
5
  SHA512:
6
- metadata.gz: 596c9921e356fdddb657a281fff86414a6fe61b72b6b6ad147b9c926eff60b778014ca91d9601140cea158ac0f97a6a2da81ef0f03f3575f75f5e185537ff668
7
- data.tar.gz: 2bafdcc04ec50997c73346374cc724e48bad480f67d8e0ac2609b781fb7e13ddfae48f04b5a9974eb4519dd3d909aaa10f499df3b94987f6006bc26520a7b6c5
6
+ metadata.gz: d57fd70a8b648df34e665a83066ff942d76149ed966889c267a81645cf55e99dbc639b9d8f926cc9dbbdd46824aa441a1eb68fd57640cd82eb6cfc9fd6a67728
7
+ data.tar.gz: 5a6b6045cff057685bb67c6b18015d4a6490db22bd22b191a8cabc29b739a0ba9efd5d54bce1ac219d0e70f35ced71bef338d3c70910fa6422921567f5f198f9
data/lib/ika/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ika
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.7'
3
3
  end
data/lib/ika.rb CHANGED
@@ -19,10 +19,10 @@ module Ika
19
19
  end
20
20
 
21
21
  ActiveRecord::Base.transaction do
22
- sync = false
23
22
  if options && options[:sync]
24
- sync = true
25
- destroy_all
23
+ remove_target_ids = all.pluck(:id)
24
+ else
25
+ remove_target_ids = []
26
26
  end
27
27
  objects.each do |object|
28
28
  record_exists = false
@@ -46,7 +46,7 @@ module Ika
46
46
  md5 = Digest::MD5.file('public' + obj_url)
47
47
  need_update = false if md5 == obj_md5 && record_exists && obj_name == Pathname(exist_object.try(key.to_sym).to_s).basename.to_s
48
48
  end
49
- if obj_url && (need_update || sync)
49
+ if obj_url && need_update
50
50
  object_params[key] = base64_conversion(obj_data, obj_name)
51
51
  elsif obj_url.blank?
52
52
  object_params[('remove_' + key).to_sym] = true
@@ -57,11 +57,14 @@ module Ika
57
57
  end
58
58
  end
59
59
  if record_exists
60
- where(id: object['id'].to_i).first.update(object_params)
60
+ exist_object.attributes = object_params
61
+ exist_object.save(validate: false)
61
62
  else
62
- create(object_params)
63
+ new(object_params).save(validate: false)
63
64
  end
65
+ remove_target_ids -= [object['id'].to_i]
64
66
  end
67
+ where(id: remove_target_ids).destroy_all
65
68
  end
66
69
  end
67
70
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ika
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makoto NAKAYA