Module: PhonyNumber::ActiveRecordExtension::ClassMethods
- Defined in:
- lib/phony_number.rb
Instance Method Summary collapse
-
#phony_normalize_numbers(*attributes) ⇒ Object
Use this method on the class level like: phony_normalize_numbers :phone_number, :fax_number, :default_country_code => ‘NL’.
Instance Method Details
#phony_normalize_numbers(*attributes) ⇒ Object
Use this method on the class level like:
phony_normalize_numbers :phone_number, :fax_number, :default_country_code => 'NL'
It checks your model object for a a country_code attribute (eg. ‘NL’) to do the normalizing so make sure you’ve geocoded before calling this method!
68 69 70 71 72 73 74 75 76 |
# File 'lib/phony_number.rb', line 68 def phony_normalize_numbers(*attributes) = attributes.last.is_a?(Hash) ? attributes.last : {} attributes.each do |attribute| # Add before validation that saves a normalized version of the phone number self.before_validation do set_phony_normalized_numbers(attributes, ) end end end |