has_contact_number 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c2cb94f73a5e4807d187713fd8731d56b6b1bc1526d5d375ceea7785ab47c68
4
- data.tar.gz: f41a2813fea7841147b1493b89a6bb27ecfa2f135bd6166c00306b8533d989d7
3
+ metadata.gz: 5d056ae179d5898609de13d5b73010177dbb06f2c3adea1947e308480d366334
4
+ data.tar.gz: 139f8bedf15eb4f3a5475c69094da19d9d283313dca38110fdd0ec60aefdf5f7
5
5
  SHA512:
6
- metadata.gz: 3ebaf7ff6dfc65a67fc559ac2722e7cbaa9c0f0578b1e263a428035af59841a2474230f61d0814721a9bbade41597042e67a1fd737775b89eaea350c8d6fdcec
7
- data.tar.gz: 48845fc9570e9b54b49feab1af10e73e43a7cc16a4533e7469212e4e640433cb2d70e94f3675f919ce5cc40cc80236bec5a3ffe22f148ca3de9adef48a1417a2
6
+ metadata.gz: 5d289a54bbce761715d0b8fbbb690cd206caa1162a30ce03102093e4792eb006c28f179047cd1f62049e976d5fcfac1e06888f3802a2233d4923bc4bfbccb3f8
7
+ data.tar.gz: e123155db191afc408839d81d6806058ae31b14d40cde2e4d4e1d1b70109335aecf78237c420977876defbd77c00d3687a5231156e7866a0b0fe896a93d09cf7
@@ -20,13 +20,19 @@ module HasContactNumber::ModelMethods
20
20
  @#{column}_isd_code ||= #{column} && #{column}[0..3]
21
21
  end
22
22
 
23
+ def #{column}_isd_code=(val)
24
+ @#{column}_isd_code = val
25
+ self.#{column} = "\#{val}\#{#{column}_without_isd_code}"
26
+ end
27
+
23
28
  def #{column}_without_isd_code
24
29
  @#{column}_without_isd_code ||= #{column} && #{column}[4..-1]
25
30
  end
26
31
 
27
- before_validation { |model|
28
- model.#{column} = model.#{column}_isd_code + model.#{column}_without_isd_code
29
- }
32
+ def #{column}_without_isd_code=(val)
33
+ @#{column}_without_isd_code = val
34
+ self.#{column} = "\#{#{column}_isd_code}\#{val}"
35
+ end
30
36
 
31
37
  validates :#{column}_isd_code, presence: true, if: proc { |model| model.#{column}_without_isd_code.present? }
32
38
  validates :#{column}_without_isd_code, presence: true, if: proc { |model| model.#{column}_isd_code.present? }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module HasContactNumber
3
3
 
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_contact_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anand Bait