ika 1.0.10 → 1.0.11

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 +10 -7
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b679ead83c1241604f025295599823f7c68ee35
4
- data.tar.gz: 25912adcc7557199a593c5a1e1d5b0a8131021b6
3
+ metadata.gz: b34bad1546023a0d1f4e1bdd9af0ae68473bbf36
4
+ data.tar.gz: 2de9d79ec32e2ea76245d2084cd59434a2248890
5
5
  SHA512:
6
- metadata.gz: 762e15750fe49a33caa15cf7cd1e7225f26fb61265776ae39b3ec6e7fea832a778e6d15332d90583516dfd3754d67ff5310fede62098d82402b008c052e30335
7
- data.tar.gz: a5256e9347cad3333c4a104612cf5ed6343f0670282eacd09d857a8d2e02e5147519f9e5e9ebcd3d177cfcf5281a99b2d7a9e58c8e75c48bb65eebba0b4bf349
6
+ metadata.gz: f023cacba74e3c8a8e606c1c6e5984678c13fcef1df440c3e6f0accaa69a62ea0830a44383904993545ba6c806079091dcfee54aa9d58d7aa9c10e92fc790b36
7
+ data.tar.gz: 0d59771a41c0250942857b65bc298b26f4c95747c8288d663ce391b03e7bda6eaa0e484d185e36ad709452ec9c8f5e5a0588c9822a0e098229eee7ee7cf5dc3c
data/lib/ika/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ika
2
- VERSION = '1.0.10'
2
+ VERSION = '1.0.11'
3
3
  end
data/lib/ika.rb CHANGED
@@ -17,6 +17,7 @@ module Ika
17
17
  objects = JSON.parse(json_or_array)
18
18
  objects = [objects] unless objects.is_a?(Array)
19
19
  end
20
+ json_or_array = nil
20
21
 
21
22
  ActiveRecord::Base.transaction do
22
23
  if options && options[:sync]
@@ -55,6 +56,7 @@ module Ika
55
56
  object_params[key] = object[key]
56
57
  end
57
58
  end
59
+ object.delete(key) if key != 'id'
58
60
  end
59
61
  if record_exists
60
62
  exist_object.attributes = object_params
@@ -63,6 +65,7 @@ module Ika
63
65
  new(object_params).save!(validate: false)
64
66
  end
65
67
  remove_target_ids -= [object['id'].to_i]
68
+ object.delete('id')
66
69
  end
67
70
  where(id: remove_target_ids).destroy_all
68
71
  end
@@ -72,12 +75,12 @@ module Ika
72
75
  ika_import(json_or_array, options)
73
76
  end
74
77
 
75
- def ika_export(options = {}, object = nil)
78
+ def ika_export(options = {}, objects = nil)
76
79
  CarrierWave::Uploader::Base.json_with_raw_data = true
77
80
  all_symbol = true
78
81
  options[:include] ||= []
79
82
  options[:include] = [options[:include]] unless options[:include].is_a?(Array)
80
- objects = self.includes(options[:include]) unless objects
83
+ objects ||= self.includes(options[:include])
81
84
  options[:include].each do |opt|
82
85
  all_symbol = false unless opt.is_a?(Symbol)
83
86
  end
@@ -106,12 +109,12 @@ module Ika
106
109
  JSON.generate(whole_obj_arr)
107
110
  end
108
111
 
109
- def export(options = {}, object = nil)
110
- ika_export(options, object)
112
+ def export(options = {}, objects = nil)
113
+ ika_export(options, objects)
111
114
  end
112
115
  end
113
116
 
114
- def ika_export(options = {}, object = nil)
117
+ def ika_export(options = {}, objects = nil)
115
118
  CarrierWave::Uploader::Base.json_with_raw_data = true
116
119
  objects ||= self
117
120
  all_symbol = true
@@ -141,8 +144,8 @@ module Ika
141
144
  JSON.generate(obj_hash)
142
145
  end
143
146
 
144
- def export(options = {}, object = nil)
145
- ika_export(options, object)
147
+ def export(options = {}, objects = nil)
148
+ ika_export(options, objects)
146
149
  end
147
150
  end
148
151
 
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.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makoto NAKAYA
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-26 00:00:00.000000000 Z
12
+ date: 2016-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails