Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #10 from makandra/ruby-1.8.7-compatibility

Compatibility with Ruby 1.8.7
  • Loading branch information...
commit 128f4f46912886cf8f45c7dbd3d5355781f58382 2 parents a69be1f + 489496e
@joost authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/phony_rails.rb
View
5 lib/phony_rails.rb
@@ -86,8 +86,9 @@ def phony_normalized_method(*attributes)
main_options = attributes.last.is_a?(Hash) ? attributes.pop : {}
main_options.assert_valid_keys :country_code, :default_country_code
attributes.each do |attribute|
- raise StandardError, "Instance method normalized_#{attribute} already exists on #{self.name} (PhonyRails)" if self.instance_methods.include?(:"normalized_#{attribute}")
- define_method :"normalized_#{attribute}" do |options = {}|
+ raise StandardError, "Instance method normalized_#{attribute} already exists on #{self.name} (PhonyRails)" if method_defined?(:"normalized_#{attribute}")
+ define_method :"normalized_#{attribute}" do |*args|
+ options = args.first || {}
raise ArgumentError, "No attribute/method #{attribute} found on #{self.class.name} (PhonyRails)" if not self.respond_to?(attribute)
options[:country_code] ||= self.country_code if self.respond_to?(:country_code)
PhonyRails.normalize_number(self.send(attribute), main_options.merge(options))
Please sign in to comment.
Something went wrong with that request. Please try again.