contacts_client 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
1
  class Email < ContactAttribute
2
+ include ActiveModel::Validations::Callbacks
3
+
2
4
  self.attribute_keys = [:_id, :_type, :public, :primary, :category, :value, :contact_id]
3
5
  self.hydra = Contacts::HYDRA
4
6
  self.resource_path = "/v0/contact_attributes"
@@ -7,6 +9,8 @@ class Email < ContactAttribute
7
9
  self.api_key = Contacts::API_KEY
8
10
  self.host = Contacts::HOST
9
11
 
12
+ before_validation :strip_whitespace
13
+
10
14
  attr_accessor :category, :value, :public, :primary
11
15
 
12
16
  def _type
@@ -14,4 +18,9 @@ class Email < ContactAttribute
14
18
  end
15
19
 
16
20
  validates :value, :email_format => true
21
+
22
+ private
23
+ def strip_whitespace
24
+ self.value = self.value.strip
25
+ end
17
26
  end
@@ -1,4 +1,6 @@
1
1
  class Telephone < ContactAttribute
2
+ include ActiveModel::Validations::Callbacks
3
+
2
4
  self.attribute_keys = [:_id, :_type, :public, :primary, :category, :value, :contact_id]
3
5
  self.hydra = Contacts::HYDRA
4
6
  self.resource_path = "/v0/contact_attributes"
@@ -9,6 +11,8 @@ class Telephone < ContactAttribute
9
11
 
10
12
  attr_accessor :category, :value, :public, :primary
11
13
 
14
+ before_validation :strip_whitespace
15
+
12
16
  validates :value, :numericality => true, :unless => :masked?
13
17
 
14
18
  def masked?
@@ -18,4 +22,9 @@ class Telephone < ContactAttribute
18
22
  def _type
19
23
  self.class.name
20
24
  end
25
+
26
+ private
27
+ def strip_whitespace
28
+ self.value = self.value.strip
29
+ end
21
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contacts_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties