Permalink
Browse files

Version 0.2.1

  • Loading branch information...
1 parent afbf889 commit aa17c5a59741a4bb55c9989070894e3ea4e1de59 @joost committed Apr 26, 2013
Showing with 14 additions and 11 deletions.
  1. +12 −9 README.md
  2. +1 −1 lib/phony_rails.rb
  3. +1 −1 lib/phony_rails/version.rb
View
@@ -27,11 +27,11 @@ In your model add:
class SomeModel < ActiveRecord::Base
- # Normalizes the attribute itself before validation
+ # Normalizes the attribute itself before validation
phony_normalize :phone_number, :default_country_code => 'US'
# Normalizes attribute before validation and saves into other attribute
- phony_normalize :phone_number, :as => :phone_number_normalized_version, :default_country_code => 'US'
+ phony_normalize :phone_number, :as => :phone_number_normalized_version, :default_country_code => 'US'
# Creates method normalized_fax_number that returns the normalized version of fax_number
phony_normalized_method :fax_number
@@ -78,11 +78,11 @@ In your views use:
<%= "311012341234".phony_formatted(:format => :international, :spaces => '-') %>
<%= "+31-10-12341234".phony_formatted(:format => :international, :spaces => '-') %>
- <%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %>
+ <%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %>
To first normalize the String to a certain country use:
- <%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %>
+ <%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %>
You can also use the bang method (phony_formatted!):
@@ -98,28 +98,31 @@ Say you want to find a record by a phone number. Best is to normalize user input
## Changelog
+0.2.1
+* Better error handling by @k4nar
+
0.1.12
* Further loosened gemspec dependencies.
0.1.11
-* Better gemspec dependency versions by rjhaveri.
+* Better gemspec dependency versions by @rjhaveri.
0.1.10
* Changes from henning-koch.
* Some pending fixes.
0.1.8
-* Improved validation methods by ddidier.
+* Improved validation methods by @ddidier.
0.1.6
* Added :as option to phony_normalize.
0.1.5
-* some tests and a helper method by ddidier.
+* some tests and a helper method by @ddidier.
0.1.2
-* Using countries gem as suggested by brutuscat.
-* Fixes bugs mentioned by ddidier.
+* Using countries gem as suggested by @brutuscat.
+* Fixes bugs mentioned by @ddidier.
0.1.0
* Added specs.
View
@@ -49,7 +49,7 @@ def set_phony_normalized_numbers(attributes, options = {})
options[:country_code] ||= self.country_code if self.respond_to?(:country_code)
attributes.each do |attribute|
attribute_name = options[:as] || attribute
- raise RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)" if not self.respond_to?(attribute_name)
+ raise RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)" if not self.attribute_method?(attribute_name)
write_attribute(attribute_name, PhonyRails.normalize_number(read_attribute(attribute), options))
end
end
@@ -1,3 +1,3 @@
module PhonyRails
- VERSION = "0.2.0"
+ VERSION = "0.2.1"
end

0 comments on commit aa17c5a

Please sign in to comment.