lib/phony_rails.rb in phony_rails-0.12.13 vs lib/phony_rails.rb in phony_rails-0.13.0
- old
+ new
@@ -6,11 +6,11 @@
module PhonyRails
def self.country_number_for(country_code)
return if country_code.nil?
- country_codes_hash[country_code.to_s.upcase]['country_code']
+ country_codes_hash.fetch(country_code.to_s.upcase, {})['country_code']
end
def self.country_codes_hash
@country_codes_hash ||= YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'data/country_codes.yaml'))
end
@@ -92,10 +92,11 @@
options[set_country_as] ||= self.country_code
end
attributes.each do |attribute|
attribute_name = options[:as] || attribute
fail(RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)") unless self.class.attribute_method?(attribute_name)
- send("#{attribute_name}=", PhonyRails.normalize_number(send(attribute), options))
+ new_value= PhonyRails.normalize_number(send(attribute), options)
+ send("#{attribute_name}=", new_value) if new_value
end
end
end
module ClassMethods