Update customer.rb

This commit is contained in:
2016-04-29 08:38:15 -04:00
parent 9750ef2f3b
commit 916a9bdb70

View File

@@ -24,7 +24,9 @@ class Customer < ActiveRecord::Base
# returns true if the customer is active # returns true if the customer is active
def active? def active?
return @details.active? if @details mutex.synchronize do
return @details.active? if @details
end
end end
# returns a human readable string # returns a human readable string
@@ -34,8 +36,10 @@ class Customer < ActiveRecord::Base
# returns the customer's email # returns the customer's email
def email def email
begin begin
return @details.email_address.address mutex.synchronize do
return @details.email_address.address
end
rescue rescue
return nil return nil
end end
@@ -43,8 +47,10 @@ class Customer < ActiveRecord::Base
# returns the customer's primary phone # returns the customer's primary phone
def primary_phone def primary_phone
begin begin
return @details.primary_phone.free_form_number mutex.synchronize do
return @details.primary_phone.free_form_number
end
rescue rescue
return nil return nil
end end
@@ -53,7 +59,9 @@ class Customer < ActiveRecord::Base
# returns the customer's mobile phone # returns the customer's mobile phone
def mobile_phone def mobile_phone
begin begin
return @details.mobile_phone.free_form_number mutex.synchronize do
return @details.mobile_phone.free_form_number
end
rescue rescue
return nil return nil
end end
@@ -61,7 +69,9 @@ class Customer < ActiveRecord::Base
# returns the customer's notes # returns the customer's notes
def notes def notes
return @details.notes if @details mutex.synchronize do
return @details.notes if @details
end
end end
# updates the customer's notes in QBO # updates the customer's notes in QBO
@@ -119,10 +129,12 @@ class Customer < ActiveRecord::Base
# update's the customers name if updated # update's the customers name if updated
def update def update
begin begin
if not self.name == @detils.display_name mutex.synchronize do
self.name = @details.display_name if not self.name == @detils.display_name
self.save self.name = @details.display_name
end self.save
end
}
rescue rescue
return nil return nil
end end