Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
check if attrs exist before comparing and stop pre-populating the ins…
…tant variable Sf::Contact#diffs
ij committed Jan 18, 2019
1 parent f2e079e commit 849228a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/sf/contact.rb
@@ -46,16 +46,7 @@ def set_person_by_email(email)
end

def get_diffs
unless self.Id.nil?
sf_person_mapping.each do |p, sf|
diffs[p.to_sym] = true unless self.send(sf).eql? person.send(p)
end
else
sf_person_mapping.each do |p, sf|
diffs[p.to_sym] = true
end
end
diffs
self.Id.nil? ? flag_all_attrbutes_as_diff : flag_attributes_if_different
end

def attrs_from_person
@@ -199,4 +190,17 @@ def self.build_contacts(from, where)
IN (SELECT Contact__c FROM #{from} where #{where})"
)
end

def flag_all_attrbutes_as_diff
sf_person_mapping.merge(sf_person_mapping) do |p, sf|
true if person.respond_to?(p)
end.compact
end

def flag_attributes_if_different
sf_person_mapping.merge(sf_person_mapping) do |p, sf|
true if person.respond_to?(p) and !self.send(sf).eql?(person.send(p))
end.compact
end

end

0 comments on commit 849228a

Please sign in to comment.