has_contact_number 0.1.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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5d056ae179d5898609de13d5b73010177dbb06f2c3adea1947e308480d366334
|
4
|
+
data.tar.gz: 139f8bedf15eb4f3a5475c69094da19d9d283313dca38110fdd0ec60aefdf5f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d289a54bbce761715d0b8fbbb690cd206caa1162a30ce03102093e4792eb006c28f179047cd1f62049e976d5fcfac1e06888f3802a2233d4923bc4bfbccb3f8
|
7
|
+
data.tar.gz: e123155db191afc408839d81d6806058ae31b14d40cde2e4d4e1d1b70109335aecf78237c420977876defbd77c00d3687a5231156e7866a0b0fe896a93d09cf7
|
@@ -1,13 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module ActionView::Helpers::FormOptionsHelper
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
OPTIONS_FOR_ISD_CODES_SELECT = IsoCountryCodes.all.map{ |icc|
|
5
|
+
{
|
6
|
+
code: icc.calling_code,
|
7
|
+
code_to_i: icc.calling_code.delete('+').to_i,
|
8
|
+
code_to_db: icc.calling_code.delete('+').rjust(4, '0'),
|
9
|
+
country: icc.name,
|
10
|
+
country_with_code: "#{icc.name} (#{icc.calling_code})"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
OPTIONS_FOR_ISD_CODES_SELECT_BY_CODE = OPTIONS_FOR_ISD_CODES_SELECT.uniq.sort_by{|record| record[:code_to_i]}.map do |record|
|
14
|
+
[record[:code], record[:code_to_db]]
|
15
|
+
end
|
16
|
+
OPTIONS_FOR_ISD_CODES_SELECT_BY_COUNTRY_NAME = OPTIONS_FOR_ISD_CODES_SELECT.sort_by{|record| record[:country]}.map do |record|
|
17
|
+
[record[:country_with_code], record[:code_to_db]]
|
18
|
+
end
|
9
19
|
|
10
|
-
|
20
|
+
def options_for_isd_code_select(display_country_names: true)
|
21
|
+
display_country_names ? OPTIONS_FOR_ISD_CODES_SELECT_BY_COUNTRY_NAME : OPTIONS_FOR_ISD_CODES_SELECT_BY_CODE
|
11
22
|
end
|
12
23
|
|
13
24
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
module HasContactNumber::ModelMethods
|
3
3
|
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
puts '---------------------HasContactNumber::ModelMethods---------------------'
|
6
5
|
module ClassMethods
|
7
6
|
|
8
7
|
def contact_number_attributes(*columns)
|
@@ -21,16 +20,22 @@ module HasContactNumber::ModelMethods
|
|
21
20
|
@#{column}_isd_code ||= #{column} && #{column}[0..3]
|
22
21
|
end
|
23
22
|
|
23
|
+
def #{column}_isd_code=(val)
|
24
|
+
@#{column}_isd_code = val
|
25
|
+
self.#{column} = "\#{val}\#{#{column}_without_isd_code}"
|
26
|
+
end
|
27
|
+
|
24
28
|
def #{column}_without_isd_code
|
25
29
|
@#{column}_without_isd_code ||= #{column} && #{column}[4..-1]
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
def #{column}_without_isd_code=(val)
|
33
|
+
@#{column}_without_isd_code = val
|
34
|
+
self.#{column} = "\#{#{column}_isd_code}\#{val}"
|
35
|
+
end
|
31
36
|
|
32
|
-
validates :#{column}_isd_code, presence: true, if:
|
33
|
-
validates :#{column}_without_isd_code, presence: true, if:
|
37
|
+
validates :#{column}_isd_code, presence: true, if: proc { |model| model.#{column}_without_isd_code.present? }
|
38
|
+
validates :#{column}_without_isd_code, presence: true, if: proc { |model| model.#{column}_isd_code.present? }
|
34
39
|
validates :#{column}, phony_plausible: true, if: proc { |model|
|
35
40
|
model.#{column}_isd_code.present? && model.#{column}_without_isd_code.present?
|
36
41
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_contact_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anand Bait
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iso_country_codes
|
@@ -124,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.5.1
|
127
|
+
rubygems_version: 3.2.7
|
129
128
|
signing_key:
|
130
129
|
specification_version: 4
|
131
130
|
summary: Phone, mobile, fax numbers with ISD code storage and validation.
|