lib/contactable.rb in twilio_contactable-0.7.6 vs lib/contactable.rb in twilio_contactable-0.8.0

- old
+ new

@@ -66,26 +66,31 @@ self.class.twilio_contactable end Attributes.each do |attr| eval %Q{ def _TC_#{attr} - read_attribute self.class.twilio_contactable.#{attr}_column + send self.class.twilio_contactable.#{attr}_column end def _TC_#{attr}=(value) - write_attribute self.class.twilio_contactable.#{attr}_column, value + send self.class.twilio_contactable.#{attr}_column.to_s+'=', value end } end + def has_valid_phone_number? + format_phone_number + _TC_formatted_phone_number =~ /^\+[\d]{11,12}$/ + end # Sends an SMS validation request through the gateway def send_sms_confirmation! return false if _TC_sms_blocked return true if sms_confirmed? return false if _TC_phone_number.blank? + format_phone_number confirmation_code = TwilioContactable.generate_confirmation_code # Use this class' confirmation_message method if it # exists, otherwise use the generic message message = (self.class.respond_to?(:confirmation_message) ? @@ -110,9 +115,10 @@ def send_voice_confirmation! return false if _TC_voice_blocked return true if voice_confirmed? return false if _TC_phone_number.blank? + format_phone_number confirmation_code = TwilioContactable.generate_confirmation_code response = TwilioContactable::Gateway.initiate_voice_call(self, _TC_formatted_phone_number) if response.success? \ No newline at end of file