validates_and_formats_phones 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ PKG_FILES = FileList[
23
23
 
24
24
  spec = Gem::Specification.new do |s|
25
25
  s.name = "validates_and_formats_phones"
26
- s.version = "0.0.2"
26
+ s.version = "0.0.3"
27
27
 
28
28
  s.author = "Bernie Telles"
29
29
  s.email = "btelles@gmail.com"
@@ -11,9 +11,11 @@
11
11
  formats = []
12
12
  fields = []
13
13
  args.each do |option|
14
- option.to_s =~ /#/ ?
15
- formats << option :
14
+ if option.to_s =~ /#/
15
+ formats << option
16
+ else
16
17
  fields << option.to_sym
18
+ end
17
19
  end
18
20
  formats << DEFAULT_FORMAT if formats.empty?
19
21
  fields << :phone if fields.empty?
@@ -30,7 +32,7 @@
30
32
  record.errors.add attr, "must have #{size_options[0]} digits."
31
33
  end
32
34
  else
33
- record.format_phone_fields(fields, formats)
35
+ record.format_phone_field(attr, formats)
34
36
  end
35
37
  end
36
38
  end
@@ -38,15 +40,9 @@
38
40
 
39
41
  module InstanceMethods
40
42
 
41
- def format_phone_fields(fields = [:phone], formats = [])
42
- formats << DEFAULT_FORMAT if formats.empty?
43
- fields.each do |field_name|
44
- format_phone_field(field_name, formats) unless send(field_name).blank?
45
- end
46
- end
47
43
  def format_phone_field(field_name, formats = [])
48
44
  formats << DEFAULT_FORMAT if formats.empty?
49
- self.send("#{field_name}=", self.send(field_name).to_s.to_phone(formats))
45
+ self.send("#{field_name}=", self.send(field_name).to_s.to_phone(formats)) unless send(field_name).blank?
50
46
  end
51
47
  end
52
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_and_formats_phones
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernie Telles
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-01 00:00:00 -05:00
12
+ date: 2010-02-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15