backframe 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/backframe/activerecord/acts_as_phone.rb +10 -5
- data/lib/backframe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddd42ad68a92951af7d447fe203cf35caefba49e
|
4
|
+
data.tar.gz: d6d17949e7f8cd763de6b45c95213d5eb5162c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde2bb19707f03d683fd87514d75cf0db6642ab86c3ba045ed0ee82e29f2e14facba701a28216001c315e523376e773994b9d4ea418193bbe26239b7abf59bd5
|
7
|
+
data.tar.gz: 060048ae6277590bf40793edbafea2af25565bc2804851d1397ffd97a46a7f4c3c7d2b92b35c80ad3632913a83d333453c14c9319bf964e896d1d3394b6cb8b2
|
@@ -17,7 +17,7 @@ module Backframe
|
|
17
17
|
|
18
18
|
class_eval <<-EOV
|
19
19
|
|
20
|
-
after_initialize :uncast_phone_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
|
20
|
+
after_initialize :uncast_phone_#{entity}, :if => Proc.new { |c| !c.new_record? && c.#{entity}.present? }
|
21
21
|
before_save :cast_phone_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
|
22
22
|
after_save :uncast_phone_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
|
23
23
|
|
@@ -30,18 +30,23 @@ module Backframe
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def cast_phone_#{entity}
|
33
|
-
self.#{entity} =
|
34
|
-
self.#{entity} = '1'+self.#{entity} if (self.#{entity}.length == 10)
|
33
|
+
self.#{entity} = #{entity}_to_international(self.#{entity})
|
35
34
|
end
|
36
35
|
|
37
36
|
def validates_phone_#{entity}
|
38
|
-
testvalue =
|
39
|
-
testvalue = '1'+testvalue if (testvalue.length == 10)
|
37
|
+
testvalue = #{entity}_to_international(self.#{entity})
|
40
38
|
if !Phony.plausible?(testvalue)
|
41
39
|
self.errors.add(:#{entity}, 'invalid #{entity} number')
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
43
|
+
def #{entity}_to_international(value)
|
44
|
+
regex = Regexp.new('[\\s\\\.\\\-\\\(\\\)]')
|
45
|
+
newvalue = value.gsub(regex, '')
|
46
|
+
newvalue = (newvalue.length == 10) ? '1'+value : value
|
47
|
+
Phony.normalize(newvalue)
|
48
|
+
end
|
49
|
+
|
45
50
|
EOV
|
46
51
|
|
47
52
|
end
|
data/lib/backframe/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backframe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Kops
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-05-
|
12
|
+
date: 2016-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: write_xlsx
|