contact_sync 1.4.2 → 1.4.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: 2d6c0a287d80841dd4a490134ea33c84a37f86a2
4
- data.tar.gz: d1138accdeec6c7335e683e38ca52ec0feb41610
3
+ metadata.gz: 0684c816809ee85db24dfa43722c0a2d224fa037
4
+ data.tar.gz: e9c0a7d4f4672409610c999ddcbd483bf7508080
5
5
  SHA512:
6
- metadata.gz: 797c299a4a8f1ca747821e83e21b0100fce5a0ef0e6851ebe7448e2a10df1f2417ee65ee4c5fa618111118a9e22556d8849f88ef5eae20fed5cacb7cae795e8e
7
- data.tar.gz: 305581805f30b1b8db6e795983951be61fa825b2f1ca400ad371c77ededeb1d945a6e548eee2d3864de3ac6796f00ce4b15fd694d5032144b537af0543bf33ff
6
+ metadata.gz: 351d271bc8482d4a7d627861c55a137bb9bcf6879ce926cc9ea6b8879a8b5ccc0144fe69ed6320ce98dcfd3109179daa66486a25e73ba847dcf2ba8fe2a9c201
7
+ data.tar.gz: 11730ca66d792814b1efb706fe85d15dfc70b87bf7245a1a7be439502ccf39a3382d5e456efb896cf95df691044eec1eb7cdb65991f2ee9b4b1d09a9dfeaf2e8
@@ -28,31 +28,32 @@ module ContactSync
28
28
  contacts.each do |aContact|
29
29
  phones = aContact[:phones]
30
30
  emails = aContact[:emails]
31
-
32
31
  aContact.delete :phones
33
32
  aContact.delete :emails
33
+ newContact = Contact.new(contact_params(aContact))
34
34
  begin
35
- newContact = Contact.new(contact_params(aContact))
35
+ # newContact = Contact.new(contact_params(aContact))
36
36
  # newContact.device_id = contact_hash[:device_id]
37
- if phones
37
+ if phones && phones.class == Array
38
38
  phones.each do |aPhone|
39
39
  newContact.phones.build(phone_params(aPhone))
40
40
  end
41
41
  end
42
- if emails
42
+ if emails && emails.class == Array
43
43
  emails.each do |anEmail|
44
44
  newContact.emails.build(email_params(anEmail))
45
45
  end
46
46
  end
47
+ self.contacts << newContact
47
48
  if newContact.save
48
49
  # result[:new][:success] << newContact.record_id
49
- self.contacts << newContact
50
50
  else
51
51
  result[:new][:failed] << newContact.record_id
52
52
  end
53
53
  rescue ActiveRecord::RecordNotUnique => e
54
54
  puts "Rescuing Duplicate Record"
55
55
  result[:new][:duplicate] << newContact.record_id
56
+ newContact.destroy
56
57
  end
57
58
  end
58
59
  end
@@ -1,3 +1,3 @@
1
1
  module ContactSync
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -7,6 +7,8 @@ class Contact < ActiveRecord::Base
7
7
  # has_many :social_profiles, :dependent => :delete_all
8
8
 
9
9
  belongs_to :user
10
+ validates_presence_of :user
11
+ validates :record_id, presence: true, numericality: {:greater_than => 0}
10
12
 
11
13
  # def jsonNotation
12
14
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contact_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saad Masood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-14 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails